oq-formatted-string

1.0.2 • Public • Published

oq-formatted-string

Replace tokens from a string with values of an object. 给定键值对或对象,得到格式化字符串

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

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!

This project belongs to OpenQuest---A open organization concentrates on reading excellent codes from npm.org and github.com and commenting them so that everyone can understand easily. You can check the index_comment.js to get the source comments. For more information, linking to https://github.com/OpenQuest.

Package Sidebar

Install

npm i oq-formatted-string

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • lingshanjun