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