PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/node_modules/lodash/curryRight.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 54 lines | 10 code | 4 blank | 40 comment | 0 complexity | 518b7749881bf764edb77988bb0ba9bb MD5 | raw file
 1var createWrap = require('./_createWrap');
 2
 3/** Used to compose bitmasks for function metadata. */
 4var WRAP_CURRY_RIGHT_FLAG = 16;
 5
 6/**
 7 * This method is like `_.curry` except that arguments are applied to `func`
 8 * in the manner of `_.partialRight` instead of `_.partial`.
 9 *
10 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
11 * builds, may be used as a placeholder for provided arguments.
12 *
13 * **Note:** This method doesn't set the "length" property of curried functions.
14 *
15 * @static
16 * @memberOf _
17 * @since 3.0.0
18 * @category Function
19 * @param {Function} func The function to curry.
20 * @param {number} [arity=func.length] The arity of `func`.
21 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
22 * @returns {Function} Returns the new curried function.
23 * @example
24 *
25 * var abc = function(a, b, c) {
26 *   return [a, b, c];
27 * };
28 *
29 * var curried = _.curryRight(abc);
30 *
31 * curried(3)(2)(1);
32 * // => [1, 2, 3]
33 *
34 * curried(2, 3)(1);
35 * // => [1, 2, 3]
36 *
37 * curried(1, 2, 3);
38 * // => [1, 2, 3]
39 *
40 * // Curried with placeholders.
41 * curried(3)(1, _)(2);
42 * // => [1, 2, 3]
43 */
44function curryRight(func, arity, guard) {
45  arity = guard ? undefined : arity;
46  var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
47  result.placeholder = curryRight.placeholder;
48  return result;
49}
50
51// Assign default placeholders.
52curryRight.placeholder = {};
53
54module.exports = curryRight;