UNPKG

awesome-string

Version:

The ultimate JavaScript string library

25 lines (24 loc) 913 B
import nilDefault from 'helper/undefined/nil_default'; import sprintf from 'format/sprintf'; /** * Produces a string according to `format`. Works exactly like <a href="#sprintf"><code>sprintf()</code></a>, * with the only difference that accepts the formatting arguments in an array `values`.<br/> * See <a href="#sprintf-format">here</a> `format` string specifications. * * @function vprintf * @static * @since 1.0.0 * @memberOf Format * @param {string} format=''] The format string. * @param {Array} replacements The array of replacements to produce the string. * @return {string} Returns the produced string. * @example * as.vprintf('%s', ['Welcome']) * // => 'Welcome' * * as.vprintf('%s has %d apples', ['Alexandra', 3]); * // => 'Alexandra has 3 apples' */ export default function vprintf(format, replacements) { return sprintf(format, ...nilDefault(replacements, [])); }