@labelu/formatter
v1.0.2
Published
A collection of universal data formatting functions.
Downloads
48
Maintainers
Readme
@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';
});