timeago.js
- Version 4.0.2
- Published
- 262 kB
- No dependencies
- MIT license
Install
npm i timeago.js
yarn add timeago.js
pnpm add timeago.js
Overview
timeago.js is a simple library (only 1kb) to used to format datetime with `*** time ago` statement. eg: '3 hours ago'. localization supported.
Index
Functions
Type Aliases
Functions
function cancel
cancel: (node?: HTMLElement) => void;
cancel a timer or all timers
Parameter node
node hosting the time string
function format
format: (date: TDate, locale?: string, opts?: Opts) => string;
format a TDate into string
Parameter date
Parameter locale
Parameter opts
function register
register: (locale: string, func: LocaleFunc) => void;
register a locale
Parameter locale
Parameter func
function render
render: ( nodes: HTMLElement | HTMLElement[] | NodeList, locale?: string, opts?: Opts) => HTMLElement[];
render a dom realtime
Parameter nodes
Parameter locale
Parameter opts
Type Aliases
type LocaleFunc
type LocaleFunc = (diff: number, idx: number, totalSec?: number) => [string, string];
type LocaleMap
type LocaleMap = Record<string, LocaleFunc>;
type Opts
type Opts = { /** the relative date */ readonly relativeDate?: TDate; /** the realtime */ readonly minInterval?: number;};
render / format options
type TDate
type TDate = Date | string | number;
type TimerPool
type TimerPool = Record<number, number>;
Package Files (5)
Dependencies (0)
No dependencies.
Dev Dependencies (23)
- @commitlint/cli
- @types/jest
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- cross-env
- eslint
- eslint-config-prettier
- husky
- jest
- jest-date-mock
- jest-electron
- jest-expect
- lint-md-cli
- lint-staged
- prettier
- rimraf
- rollup
- rollup-plugin-node-resolve
- rollup-plugin-typescript
- rollup-plugin-uglify
- size-limit
- ts-jest
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/timeago.js
.
- Markdown[](https://www.jsdocs.io/package/timeago.js)
- HTML<a href="https://www.jsdocs.io/package/timeago.js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1879 ms. - Missing or incorrect documentation? Open an issue for this package.