Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / function / wrap.js
1 var createWrapper = require('../internal/createWrapper'),
2     identity = require('../utility/identity');
3
4 /** Used to compose bitmasks for wrapper metadata. */
5 var PARTIAL_FLAG = 32;
6
7 /**
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.
12  *
13  * @static
14  * @memberOf _
15  * @category Function
16  * @param {*} value The value to wrap.
17  * @param {Function} wrapper The wrapper function.
18  * @returns {Function} Returns the new function.
19  * @example
20  *
21  * var p = _.wrap(_.escape, function(func, text) {
22  *   return '<p>' + func(text) + '</p>';
23  * });
24  *
25  * p('fred, barney, & pebbles');
26  * // => '<p>fred, barney, &amp; pebbles</p>'
27  */
28 function wrap(value, wrapper) {
29   wrapper = wrapper == null ? identity : wrapper;
30   return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
31 }
32
33 module.exports = wrap;