1.0.2 • Published 6 years ago

to-fmt v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Convert template literal to formatter function.

npm Travis npm.io npm.io npm.io npm

Install

With npm:

npm i to-fmt

Usage

Hello world example:

import f from 'to-fmt';

const format = f`Hello, ${String}!`;

format('World'); // -> 'Hello, World!'

Number formatter:

import f from 'to-fmt';

const toFixed = n => number => number.toFixed(n);

const format = f`Value is ${toFixed(2)}!`;

format(1); // -> 'Value is 1.00!'
format(3.14159); // -> 'Value is 3.14!'

Multiple values example:

import f from 'to-fmt';
import bytes from 'pretty-bytes';

const format = f`"${String}" size is ${bytes}!`;

format('index.js', 605); // -> '"index.js" size is 605 B'

License

MIT.

Copyright

© 2018, Rumkin.

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago