4fdb470bc133d2eae2f4fe37a341b9d87f930252
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / partialRight.js
1 var createWrapper = require('./_createWrapper'),
2     replaceHolders = require('./_replaceHolders'),
3     rest = require('./rest');
4
5 /** Used to compose bitmasks for wrapper metadata. */
6 var PARTIAL_RIGHT_FLAG = 64;
7
8 /**
9  * This method is like `_.partial` except that partially applied arguments
10  * are appended to those provided to the new function.
11  *
12  * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
13  * builds, may be used as a placeholder for partially applied arguments.
14  *
15  * **Note:** This method doesn't set the "length" property of partially
16  * applied functions.
17  *
18  * @static
19  * @memberOf _
20  * @category Function
21  * @param {Function} func The function to partially apply arguments to.
22  * @param {...*} [partials] The arguments to be partially applied.
23  * @returns {Function} Returns the new partially applied function.
24  * @example
25  *
26  * var greet = function(greeting, name) {
27  *   return greeting + ' ' + name;
28  * };
29  *
30  * var greetFred = _.partialRight(greet, 'fred');
31  * greetFred('hi');
32  * // => 'hi fred'
33  *
34  * // Partially applied with placeholders.
35  * var sayHelloTo = _.partialRight(greet, 'hello', _);
36  * sayHelloTo('fred');
37  * // => 'hello fred'
38  */
39 var partialRight = rest(function(func, partials) {
40   var placeholder = partialRight.placeholder,
41       holders = replaceHolders(partials, placeholder);
42
43   return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
44 });
45
46 // Assign default placeholders.
47 partialRight.placeholder = {};
48
49 module.exports = partialRight;