1 var createWrapper = require('../internal/createWrapper'),
2 identity = require('../utility/identity');
4 /** Used to compose bitmasks for wrapper metadata. */
8 * Creates a function that provides `value` to the wrapper function as its
9 * first argument. Any additional arguments provided to the function are
10 * appended to those provided to the wrapper function. The wrapper is invoked
11 * with the `this` binding of the created function.
16 * @param {*} value The value to wrap.
17 * @param {Function} wrapper The wrapper function.
18 * @returns {Function} Returns the new function.
21 * var p = _.wrap(_.escape, function(func, text) {
22 * return '<p>' + func(text) + '</p>';
25 * p('fred, barney, & pebbles');
26 * // => '<p>fred, barney, & pebbles</p>'
28 function wrap(value, wrapper) {
29 wrapper = wrapper == null ? identity : wrapper;
30 return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
33 module.exports = wrap;