exframe-string-formatters

1.4.5 • Public • Published

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' }

Readme

Keywords

none

Package Sidebar

Install

npm i exframe-string-formatters

Weekly Downloads

43

Version

1.4.5

License

ISC

Unpacked Size

17.8 kB

Total Files

12

Last publish

Collaborators

  • exzeodevops