diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/lodash/fp/_baseConvert.js | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'node_modules/lodash/fp/_baseConvert.js')
-rw-r--r-- | node_modules/lodash/fp/_baseConvert.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/node_modules/lodash/fp/_baseConvert.js b/node_modules/lodash/fp/_baseConvert.js index 524498526..7af27655b 100644 --- a/node_modules/lodash/fp/_baseConvert.js +++ b/node_modules/lodash/fp/_baseConvert.js @@ -1,6 +1,9 @@ var mapping = require('./_mapping'), fallbackHolder = require('./placeholder'); +/** Built-in value reference. */ +var push = Array.prototype.push; + /** * Creates a function, with an arity of `n`, that invokes `func` with the * arguments it receives. @@ -62,6 +65,37 @@ function createCloner(func) { } /** + * A specialized version of `_.spread` which flattens the spread array into + * the arguments of the invoked `func`. + * + * @private + * @param {Function} func The function to spread arguments over. + * @param {number} start The start position of the spread. + * @returns {Function} Returns the new function. + */ +function flatSpread(func, start) { + return function() { + var length = arguments.length, + lastIndex = length - 1, + args = Array(length); + + while (length--) { + args[length] = arguments[length]; + } + var array = args[start], + otherArgs = args.slice(0, start); + + if (array) { + push.apply(otherArgs, array); + } + if (start != lastIndex) { + push.apply(otherArgs, args.slice(start + 1)); + } + return func.apply(this, otherArgs); + }; +} + +/** * Creates a function that wraps `func` and uses `cloner` to clone the first * argument it receives. * @@ -141,7 +175,6 @@ function baseConvert(util, name, func, options) { 'iteratee': util.iteratee, 'keys': util.keys, 'rearg': util.rearg, - 'spread': util.spread, 'toInteger': util.toInteger, 'toPath': util.toPath }; @@ -155,7 +188,6 @@ function baseConvert(util, name, func, options) { isFunction = helpers.isFunction, keys = helpers.keys, rearg = helpers.rearg, - spread = helpers.spread, toInteger = helpers.toInteger, toPath = helpers.toPath; @@ -282,7 +314,7 @@ function baseConvert(util, name, func, options) { var data = mapping.methodSpread[name], start = data && data.start; - return start === undefined ? ary(func, n) : spread(func, start); + return start === undefined ? ary(func, n) : flatSpread(func, start); } return func; } @@ -452,8 +484,8 @@ function baseConvert(util, name, func, options) { each(aryMethodKeys, function(aryKey) { each(mapping.aryMethod[aryKey], function(otherName) { if (realName == otherName) { - var spreadData = mapping.methodSpread[realName], - afterRearg = spreadData && spreadData.afterRearg; + var data = mapping.methodSpread[realName], + afterRearg = data && data.afterRearg; result = afterRearg ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey) |