source: imaps-frontend/node_modules/lodash-es/_createCurry.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[d565449]1import apply from './_apply.js';
2import createCtor from './_createCtor.js';
3import createHybrid from './_createHybrid.js';
4import createRecurry from './_createRecurry.js';
5import getHolder from './_getHolder.js';
6import replaceHolders from './_replaceHolders.js';
7import root from './_root.js';
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
46export default createCurry;
Note: See TracBrowser for help on using the repository browser.