Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.02 KB

README.md

File metadata and controls

41 lines (28 loc) · 1.02 KB

fmt

CircleCI Codecov

Note
Segment has paused maintenance on this project, but may return it to an active status in the future. Issues and pull requests from external contributors are not being considered, although internal contributions may appear from time to time. The project remains available under its open source license for anyone to use.

util.format-like string format utility.

Installation

$ npm install @segment/fmt

Example

fmt('%d %s %o', '0n', 'str', {});
// => "0 str {}"

fmt.f = function(n){
  return Number(n || 0).toFixed(2);
};

fmt('floats: %f', 1);
// => "floats: 1.00"

API

fmt(str, ...)

Format the given str with ... args.

`%o`: JSON.stringify
`%d`: parseInt
`%s`: String