1.4.5 • Published 2 months ago

exframe-string-formatters v1.4.5

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
2 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.5

2 months ago

1.4.4

7 months ago

1.4.3

8 months ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago