Skip to content

segmentio/fmt

 
 

Repository files navigation

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

Packages

No packages published

Languages

  • JavaScript 69.1%
  • Makefile 30.9%