custom-util-format

1.0.0 • Public • Published

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(* 100)}%`
})
 
console.log(format('msg: %p complete', 0.5));
// => 'msg: 50% complete'

/custom-util-format/

    Package Sidebar

    Install

    npm i custom-util-format

    Weekly Downloads

    199

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • spalger