@kingjs/string-ex.expand
v1.0.0
Published
Given a string with the format of a template literal, expand its placeholders with the values corresponding to a descriptor's keys.
Downloads
12
Readme
@kingjs/string-ex.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-ex.expand');
var foo = 'bar';
var result = 'Key "foo" is "${foo}"'[Expand]({ 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-ex.expand
Source
https://repository.kingjs.net/string-ex/expand
License
MIT