@encodable/format
Utilities for managing time and number formats.
Built on top of D3 formats and support customizing your own formatters.
Install
npm install @encodable/format global-box
Example usage
import {
getTimeFormat,
formatTime,
getNumberFormat,
formatNumber,
getNumberFormatterRegistry,
} from '@encodable/format';
const numFormatFn = getNumberFormat('.2f');
const timeFormatFn = getTimeFormat('%Y-%m-%d');
formatNumber('.2f', 200);
formatTime('%Y-%m-%d', new Date());
getNumberFormatterRegistry().registerValue('my-format', (x) => `haha:${x}`);
formatNumber('my-format', 200);