1.4.6 • Published 4 months ago

exframe-string-formatters v1.4.6

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
4 months ago

exframe-string-formatters

A collection of various functions that create formatted strings (e.g. currency, date, etc). This module was created as a compliment to JSON Transpose to provide common formatting functions compatible with the customObjects parameter, but can be used independently if desired.

Date formatters are using moment-timezone, see the docs for details about supported format string.

Currency formatters are using Intl.NumberFormat and support the same options.

Usage

const { formatPhoneNumber } = require('exframe-string-formatters');

console.log(formatPhoneNumber(5558675309));
$ node example.js
(555) 867-5309

Using with JSON Transpose

This module exports an object that can be passed directly to the customObjects parameter of JSON Transpose.

const stringFormatters = require('exframe-string-formatters');
const { compile } = require('json-transpose');

const transform = compile({
  totalCost: '${formatPhoneNumber(it.primaryPhone)}'
}, {
  customObjects: stringFormatters
});

const transformed = transform({
  primaryPhone: 5558675309
});

console.log(transformed);
$ node example.js
{ primaryPhone: '(555) 867-5309' }
1.4.6

4 months ago

1.4.5

1 year ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago