diff options
Diffstat (limited to 'node_modules/lodash/fp')
-rw-r--r-- | node_modules/lodash/fp/_baseConvert.js | 42 | ||||
-rw-r--r-- | node_modules/lodash/fp/_mapping.js | 3 | ||||
-rw-r--r-- | node_modules/lodash/fp/_util.js | 1 |
3 files changed, 39 insertions, 7 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) diff --git a/node_modules/lodash/fp/_mapping.js b/node_modules/lodash/fp/_mapping.js index cbbcd99df..8f5ddf2d0 100644 --- a/node_modules/lodash/fp/_mapping.js +++ b/node_modules/lodash/fp/_mapping.js @@ -167,7 +167,8 @@ exports.iterateeAry = { /** Used to map method names to iteratee rearg configs. */ exports.iterateeRearg = { - 'mapKeys': [1] + 'mapKeys': [1], + 'reduceRight': [1, 0] }; /** Used to map method names to rearg configs. */ diff --git a/node_modules/lodash/fp/_util.js b/node_modules/lodash/fp/_util.js index f8148129e..708446302 100644 --- a/node_modules/lodash/fp/_util.js +++ b/node_modules/lodash/fp/_util.js @@ -9,7 +9,6 @@ module.exports = { 'iteratee': require('../iteratee'), 'keys': require('../_baseKeys'), 'rearg': require('../rearg'), - 'spread': require('../spread'), 'toInteger': require('../toInteger'), 'toPath': require('../toPath') }; |