time-ago-lite

1.0.3 • Public • Published

time-ago-lite

A liteweight library to generate time ago string from a date

Installation

$ yarn add time-ago-lite

or

$ npm add time-ago-lite

Usage

English (default)

import { relativeTimeEn } from 'time-ago-lite';

const yourRelativeTimeString = relativeTimeEn(yourDate);

Other languages

import { relativeTime, wordsFn } from 'time-ago-lite';

/**
 * Words function based on your language rules
 * It needs to conform to the wordsFn interface
 */
const yourLangWords: wordsFn = (number = 1, unitKey = 'now', isInPast = true) => {
    // Your implementation here, see the `enWords` in the `index.ts`
    // or `srWords` in the `index.spec.ts`
};

const relativeTimeYourLang = relativeTime(yourLangWords);

const yourRelativeTimeStringInYourLang = relativeTimeYourLang(yourDate)

Package Sidebar

Install

npm i time-ago-lite

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

7.32 kB

Total Files

7

Last publish

Collaborators

  • uranium93