string-format-obj

Replace tokens from a string with values of an object

MIT 4 个版本
安装
npm install string-format-obj
yarn add string-format-obj
pnpm add string-format-obj
bun add string-format-obj
README

string-format-obj

Replace tokens from a string with values of an object.

$ npm install --save string-format-obj
var format = require('string-format-obj');

format('{greeting} {thing}!', {
  greeting: 'Hello',
  thing: 'world'
});
// Hello world!

If you want to cache the string

var formatFunc = format('{greeting} {thing}!');

formatFunc({
  greeting: 'Howdy',
  thing: 'doody'
});
// Howdy doody!
版本列表
1.1.1 2018-01-05
1.1.0 2016-03-24
1.0.1 2015-07-31
1.0.0 2015-07-30