Sha256: dcfebf623523363f0c24faf07c6763fa004883d8bc2e5f2c0e1a1244ed8fdcaf
Contents?: true
Size: 871 Bytes
Versions: 276
Compression:
Stored size: 871 Bytes
Contents
var castFunction = require('./_castFunction'), partial = require('./partial'); /** * Creates a function that provides `value` to `wrapper` as its first * argument. Any additional arguments provided to the function are appended * to those provided to the `wrapper`. The wrapper is invoked with the `this` * binding of the created function. * * @static * @memberOf _ * @since 0.1.0 * @category Function * @param {*} value The value to wrap. * @param {Function} [wrapper=identity] The wrapper function. * @returns {Function} Returns the new function. * @example * * var p = _.wrap(_.escape, function(func, text) { * return '<p>' + func(text) + '</p>'; * }); * * p('fred, barney, & pebbles'); * // => '<p>fred, barney, & pebbles</p>' */ function wrap(value, wrapper) { return partial(castFunction(wrapper), value); } module.exports = wrap;
Version data entries
276 entries across 274 versions & 30 rubygems