1.0.0 • Published 8 years ago

custom-util-format v1.0.0

Weekly downloads
23
License
MIT
Repository
github
Last release
8 years ago

custom-util-format

A customizable version of the util.format() function from the node.js stdlib.

Create a customized format() function by passing an object of custom flags. Each key should be a single character flag, and each value a function that formats the argument for that flag. These flags will be merged with the default s, d, and j flags. Pass any falsey value to override them.

usage

const format = require('custom-util-format')({
  p: x => `${Math.round(x * 100)}%`
})

console.log(format('msg: %p complete', 0.5));
// => 'msg: 50% complete'