51dcf2fee6b0fb5ae5d5f53feaa1299df8f21749
[yaffs-website] / node_modules / uncss / node_modules / lodash / wrap.js
1 var identity = require('./identity'),
2     partial = require('./partial');
3
4 /**
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.
9  *
10  * @static
11  * @memberOf _
12  * @category Function
13  * @param {*} value The value to wrap.
14  * @param {Function} wrapper The wrapper function.
15  * @returns {Function} Returns the new function.
16  * @example
17  *
18  * var p = _.wrap(_.escape, function(func, text) {
19  *   return '<p>' + func(text) + '</p>';
20  * });
21  *
22  * p('fred, barney, & pebbles');
23  * // => '<p>fred, barney, &amp; pebbles</p>'
24  */
25 function wrap(value, wrapper) {
26   wrapper = wrapper == null ? identity : wrapper;
27   return partial(wrapper, value);
28 }
29
30 module.exports = wrap;