1.0.0 • Published 5 years ago
@kingjs/string.expand v1.0.0
@kingjs/string.expand
Given a string with the format of a template literal, expand its placeholders with the values corresponding to a descriptor's keys.
Usage
var assert = require('assert');
var expand = require('@kingjs/string.expand');
var foo = 'bar';
var result = expand.call('Key "foo" is "${foo}"', { foo });
assert('Key "foo" is "bar"' == result);
API
expand(this[, descriptor])
Parameters
this
: A string with the format of a template literal.descriptor
: The values to substitute for the placeholders inthis
.
Returns
A string whose placeholder have been replaced with the values of the corresponding descriptor keys.
Install
With npm installed, run
$ npm install @kingjs/string.expand
Source
https://repository.kingjs.net/string/expand
License
MIT
1.0.0
5 years ago