source: trip-planner-front/node_modules/lodash/_createCurry.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1var apply = require('./_apply'),
2 createCtor = require('./_createCtor'),
3 createHybrid = require('./_createHybrid'),
4 createRecurry = require('./_createRecurry'),
5 getHolder = require('./_getHolder'),
6 replaceHolders = require('./_replaceHolders'),
7 root = require('./_root');
8
9/**
10 * Creates a function that wraps `func` to enable currying.
11 *
12 * @private
13 * @param {Function} func The function to wrap.
14 * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
15 * @param {number} arity The arity of `func`.
16 * @returns {Function} Returns the new wrapped function.
17 */
18function createCurry(func, bitmask, arity) {
19 var Ctor = createCtor(func);
20
21 function wrapper() {
22 var length = arguments.length,
23 args = Array(length),
24 index = length,
25 placeholder = getHolder(wrapper);
26
27 while (index--) {
28 args[index] = arguments[index];
29 }
30 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
31 ? []
32 : replaceHolders(args, placeholder);
33
34 length -= holders.length;
35 if (length < arity) {
36 return createRecurry(
37 func, bitmask, createHybrid, wrapper.placeholder, undefined,
38 args, holders, undefined, undefined, arity - length);
39 }
40 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
41 return apply(fn, this, args);
42 }
43 return wrapper;
44}
45
46module.exports = createCurry;
Note: See TracBrowser for help on using the repository browser.