1 var castFunction = require('./_castFunction'),
2 partial = require('./partial');
5 * Creates a function that provides `value` to `wrapper` as its first
6 * argument. Any additional arguments provided to the function are appended
7 * to those provided to the `wrapper`. The wrapper is invoked with the `this`
8 * binding of the created function.
14 * @param {*} value The value to wrap.
15 * @param {Function} [wrapper=identity] The wrapper function.
16 * @returns {Function} Returns the new function.
19 * var p = _.wrap(_.escape, function(func, text) {
20 * return '<p>' + func(text) + '</p>';
23 * p('fred, barney, & pebbles');
24 * // => '<p>fred, barney, & pebbles</p>'
26 function wrap(value, wrapper) {
27 return partial(castFunction(wrapper), value);
30 module.exports = wrap;