JSPM

a-while-ago

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q47156F
  • License MIT

It happened a while ago

Package Exports

  • a-while-ago

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (a-while-ago) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


Install

$ npm install a-while-ago

Usage

const awa = require('a-while-ago');

console.log(awa(new Date() - 1000));
// => a second ago

API

awa(date)

  • date: A past date
Example:
awa(new Date() - 1000)
// => a second ago

awa(new Date() - 60 * 2000);
// => 2 minutes ago

awa(date, short)

  • date: A past date
  • short (boolean): A past date
Example:
awa(new Date() - 60 * 2000, true);
// => 2m

Todo

  • Support for sufix object instead of a boolean value.

Current:

awa(new Date() - 60 * 2000, true);
// => 2m

Desired behavior

awa(new Date() - 60 * 2000, { short: true });
// => 2m

awa(new Date() - 60 * 2000, { short: false });
// => 2 minutes ago

License

MIT License © Carlos Abraham