@labelu/formatter
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@labelu/formatter

A formatter set for sinan.

Usage

npm install @labelu/formatter
# or
yarn add @labelu/formatter

basename

import formatter from '@labelu/formatter';

formatter.format('basename', 'foo/bar/baz/asdf/quux.html');
// => 'quux.html'

fileSize

See more options in filesize.js.

import formatter from '@labelu/formatter';

formatter.format('fileSize', 265318);
// => '259.1 KB'

date

See more options in dayjs.

import formatter from '@labelu/formatter';

formatter.format('date', 1670916924956, {
  style: 'YYYY-MM-DD HH:mm',
});
// => '2022-12-13 15:36'

extension

import formatter from '@labelu/formatter';

formatter.format('extension', 'foo/bar/baz/asdf/quux.html');
// => 'html'

Add Your Own Formatter

import formatter from '@labelu/formatter';

formatter.add('foo', (value: string) => {
  return value + 'foo';
});

Package Sidebar

Install

npm i @labelu/formatter

Weekly Downloads

34

Version

1.0.2

License

Apache-2.0

Unpacked Size

32.4 kB

Total Files

18

Last publish

Collaborators

  • garyshen