Bump to v4.0.1.

This commit is contained in:
John-David Dalton
2016-01-13 00:57:48 -08:00
parent 0646bacd86
commit d8d0500f37
74 changed files with 4476 additions and 510 deletions

View File

@@ -1,4 +1,4 @@
# lodash v4.0.0
# lodash v4.0.1
The [lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
@@ -11,24 +11,26 @@ $ lodash -d -o ./lodash.js
## Installation
Using npm:
```bash
$ {sudo -H} npm i -g npm
$ npm i --save lodash
```
In Node.js:
```js
// load the modern build
// load the full build
var _ = require('lodash');
// load the core build
var _ = require('lodash/core');
// load the fp build
var _ = require('lodash/fp');
// or a method category
var array = require('lodash/array');
// or a method (great for smaller builds with browserify/webpack)
var chunk = require('lodash/chunk');
```
See the [package source](https://github.com/lodash/lodash/tree/4.0.0-npm) for more details.
See the [package source](https://github.com/lodash/lodash/tree/4.0.1-npm) for more details.
**Note:**<br>
Dont assign values to the [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL.<br>
@@ -36,7 +38,7 @@ Install [n_](https://www.npmjs.com/package/n_) for a REPL that includes lodash b
## Module formats
lodash is also available in a variety of other builds & module formats.
Lodash is also available in a variety of other builds & module formats.
* [lodash](https://www.npmjs.com/package/lodash) & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) packages
* [lodash-amd](https://www.npmjs.com/package/lodash-amd)
@@ -52,5 +54,5 @@ lodash is also available in a variety of other builds & module formats.
## Support
Tested in Chrome 46-47, Firefox 42-43, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10.x, 0.12.x, 4.x, & 5.x, &amp; PhantomJS 1.9.8.
Tested in Chrome 46-47, Firefox 42-43, IE 9-11, Edge 13, Safari 8-9, Node.js 0.10.x, 0.12.x, 4.x, & 5.x, & PhantomJS 1.9.8.
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.

View File

@@ -29,7 +29,7 @@ var copyObjectWith = require('./internal/copyObjectWith'),
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, customizer) {
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
});

View File

@@ -28,7 +28,7 @@ var copyObjectWith = require('./internal/copyObjectWith'),
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, customizer) {
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
});

View File

@@ -17,7 +17,7 @@ var baseClone = require('./internal/baseClone');
* }
* }
*
* var el = _.cloneDeep(document.body, customizer);
* var el = _.cloneDeepWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false

View File

@@ -4,7 +4,7 @@ var baseClone = require('./internal/baseClone');
* This method is like `_.clone` except that it accepts `customizer` which
* is invoked to produce the cloned value. If `customizer` returns `undefined`
* cloning is handled by the method instead. The `customizer` is invoked with
* up to five arguments; (value [, index|key, object, stack]).
* up to four arguments; (value [, index|key, object, stack]).
*
* @static
* @memberOf _
@@ -20,7 +20,7 @@ var baseClone = require('./internal/baseClone');
* }
* }
*
* var el = _.clone(document.body, customizer);
* var el = _.cloneWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false

View File

@@ -25,8 +25,11 @@ var arrayConcat = require('./internal/arrayConcat'),
* // => [1]
*/
var concat = rest(function(array, values) {
if (!isArray(array)) {
array = array == null ? [] : [Object(array)];
}
values = baseFlatten(values);
return arrayConcat(isArray(array) ? array : [Object(array)], values);
return arrayConcat(array, values);
});
module.exports = concat;

View File

@@ -23,7 +23,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* [_.matches({ 'a': 1 }), _.constant('matches A')],
* [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
* [_.constant(true), _.constant('no match')]
* ])
* ]);
*
* func({ 'a': 1, 'b': 2 });
* // => 'matches A'

3857
core.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*

View File

@@ -5,12 +5,16 @@ var deburrLetter = require('./internal/deburrLetter'),
var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
/** Used to compose unicode character classes. */
var rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0';
/** Used to compose unicode capture groups. */
var rsCombo = '[' + rsComboRange + ']';
var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']';
/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo, 'g');
/**

1
extend.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./assignIn');

1
extendWith.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./assignInWith');

3
fp.js
View File

@@ -1 +1,2 @@
module.exports = require('./fp/convert.js')();
var _ = require('./lodash').noConflict().runInContext();
module.exports = require('./fp/convert')(_);

View File

@@ -1,5 +1,6 @@
var mapping = require('./mapping.js'),
mutateMap = mapping.mutateMap;
var mapping = require('./_mapping'),
mutateMap = mapping.mutate,
placeholder = {};
/**
* The base implementation of `convert` which accepts a `util` object of methods
@@ -39,21 +40,16 @@ function baseConvert(util, name, func) {
keys = _.keys,
rearg = _.rearg;
var baseAry = function(func, n) {
return function() {
var args = arguments,
length = Math.min(args.length, n);
var baseArity = function(func, n) {
return n == 2
? function(a, b) { return func.apply(undefined, arguments); }
: function(a) { return func.apply(undefined, arguments); };
};
switch (length) {
case 1: return func(args[0]);
case 2: return func(args[0], args[1]);
}
args = Array(length);
while (length--) {
args[length] = arguments[length];
}
return func.apply(undefined, args);
};
var baseAry = function(func, n) {
return n == 2
? function(a, b) { return func(a, b); }
: function(a) { return func(a); };
};
var cloneArray = function(array) {
@@ -82,6 +78,13 @@ function baseConvert(util, name, func) {
});
};
var iterateeRearg = function(func, indexes) {
return overArg(func, function(func) {
var n = indexes.length;
return baseArity(rearg(baseAry(func, n), indexes), n);
});
};
var overArg = function(func, iteratee, retArg) {
return function() {
var length = arguments.length,
@@ -98,7 +101,10 @@ function baseConvert(util, name, func) {
var wrappers = {
'iteratee': function(iteratee) {
return function(func, arity) {
return function() {
var func = arguments[0],
arity = arguments[1];
arity = arity > 2 ? (arity - 2) : 1;
func = iteratee(func);
var length = func.length;
@@ -158,14 +164,18 @@ function baseConvert(util, name, func) {
}
var result;
each(mapping.caps, function(cap) {
each(mapping.aryMethodMap[cap], function(otherName) {
each(mapping.aryMethod[cap], function(otherName) {
if (name == otherName) {
var indexes = mapping.iterateeRearg[name],
n = !isLib && mapping.aryIteratee[name];
result = ary(func, cap);
if (cap > 1 && !mapping.skipReargMap[name]) {
result = rearg(result, mapping.methodReargMap[name] || mapping.aryReargMap[cap]);
if (cap > 1 && !mapping.skipRearg[name]) {
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
}
var n = !isLib && mapping.aryIterateeMap[name];
if (n) {
if (indexes) {
result = iterateeRearg(result, indexes);
} else if (n) {
result = iterateeAry(result, n);
}
if (cap > 1) {
@@ -176,7 +186,12 @@ function baseConvert(util, name, func) {
});
return !result;
});
return result || func;
result || (result = func);
if (mapping.placeholder[name]) {
result.placeholder = placeholder;
}
return result;
};
if (!isLib) {
@@ -185,8 +200,8 @@ function baseConvert(util, name, func) {
// Iterate over methods for the current ary cap.
var pairs = [];
each(mapping.caps, function(cap) {
each(mapping.aryMethodMap[cap], function(key) {
var func = _[mapping.keyMap[key] || key];
each(mapping.aryMethod[cap], function(key) {
var func = _[mapping.key[key] || key];
if (func) {
pairs.push([key, wrap(key, func)]);
}
@@ -200,7 +215,7 @@ function baseConvert(util, name, func) {
// Wrap the lodash method and its aliases.
each(keys(_), function(key) {
each(mapping.aliasMap[key] || [], function(alias) {
each(mapping.alias[key] || [], function(alias) {
_[alias] = _[key];
});
});

13
fp/_convertBrowser.js Normal file
View File

@@ -0,0 +1,13 @@
var baseConvert = require('./_baseConvert');
/**
* Converts `lodash` to an immutable auto-curried iteratee-first data-last version.
*
* @param {Function} lodash The lodash function.
* @returns {Function} Returns the converted `lodash`.
*/
function browserConvert(lodash) {
return baseConvert(lodash, lodash);
}
module.exports = browserConvert;

202
fp/_mapping.js Normal file
View File

@@ -0,0 +1,202 @@
module.exports = {
/** Used to map method names to their aliases. */
'alias': {
'ary': ['nAry'],
'assignIn': ['extend'],
'assignInWith': ['extendWith'],
'filter': ['whereEq'],
'flatten': ['unnest'],
'flow': ['pipe'],
'flowRight': ['compose'],
'forEach': ['each'],
'forEachRight': ['eachRight'],
'get': ['path', 'prop'],
'getOr': ['pathOr', 'propOr'],
'head': ['first'],
'includes': ['contains'],
'initial': ['init'],
'isEqual': ['equals'],
'mapValues': ['mapObj'],
'matchesProperty': ['pathEq'],
'omit': ['dissoc', 'omitAll'],
'overArgs': ['useWith'],
'overEvery': ['allPass'],
'overSome': ['somePass'],
'pick': ['pickAll'],
'propertyOf': ['propOf'],
'rest': ['unapply'],
'some': ['all'],
'spread': ['apply'],
'zipObject': ['zipObj']
},
/** Used to map method names to their iteratee ary. */
'aryIteratee': {
'assignWith': 2,
'assignInWith': 2,
'cloneDeepWith': 1,
'cloneWith': 1,
'dropRightWhile': 1,
'dropWhile': 1,
'every': 1,
'filter': 1,
'find': 1,
'findIndex': 1,
'findKey': 1,
'findLast': 1,
'findLastIndex': 1,
'findLastKey': 1,
'flatMap': 1,
'forEach': 1,
'forEachRight': 1,
'forIn': 1,
'forInRight': 1,
'forOwn': 1,
'forOwnRight': 1,
'isEqualWith': 2,
'isMatchWith': 2,
'map': 1,
'mapKeys': 1,
'mapValues': 1,
'partition': 1,
'reduce': 2,
'reduceRight': 2,
'reject': 1,
'remove': 1,
'some': 1,
'takeRightWhile': 1,
'takeWhile': 1,
'times': 1,
'transform': 2
},
/** Used to map ary to method names. */
'aryMethod': {
1:[
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
],
2:[
'add', 'after', 'ary', 'assign', 'at', 'before', 'bind', 'bindKey',
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq',
'every', 'extend', 'filter', 'find', 'find', 'findIndex', 'findKey',
'findLast', 'findLastIndex', 'findLastKey', 'flatMap', 'forEach',
'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get',
'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection',
'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf',
'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy',
'merge', 'minBy', 'omit', 'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd',
'padStart', 'parseInt', 'partition', 'pick', 'pickBy', 'pull', 'pullAll',
'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove',
'repeat', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex',
'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy',
'split', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile',
'takeWhile', 'tap', 'throttle', 'thru', 'times', 'truncate', 'union', 'uniqBy',
'uniqWith', 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject'
],
3:[
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
'unionWith', 'xorBy', 'xorWith', 'zipWith'
],
4:[
'fill', 'setWith'
]
},
/** Used to map ary to rearg configs. */
'aryRearg': {
2: [1, 0],
3: [2, 1, 0],
4: [3, 2, 0, 1]
},
/** Used to map method names to iteratee rearg configs. */
'iterateeRearg': {
'findKey': [1],
'findLastKey': [1],
'mapKeys': [1]
},
/** Used to map method names to rearg configs. */
'methodRearg': {
'clamp': [2, 0, 1],
'reduce': [2, 0, 1],
'reduceRight': [2, 0, 1],
'set': [2, 0, 1],
'setWith': [3, 1, 2, 0],
'slice': [2, 0, 1],
'transform': [2, 0, 1]
},
/** Used to iterate `mapping.aryMethod` keys. */
'caps': [1, 2, 3, 4],
/** Used to map keys to other keys. */
'key': {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
},
/** Used to identify methods which mutate arrays or objects. */
'mutate': {
'array': {
'fill': true,
'pull': true,
'pullAll': true,
'pullAllBy': true,
'pullAt': true,
'remove': true,
'reverse': true
},
'object': {
'assign': true,
'assignIn': true,
'assignInWith': true,
'assignWith': true,
'defaults': true,
'defaultsDeep': true,
'merge': true,
'mergeWith': true
},
'set': {
'set': true,
'setWith': true
}
},
/** Used to track methods with placeholder support */
'placeholder': {
'bind': true,
'bindKey': true,
'curry': true,
'curryRight': true,
'partial': true,
'partialRight': true
},
/** Used to track methods that skip `_.rearg`. */
'skipRearg': {
'assign': true,
'assignIn': true,
'concat': true,
'defaults': true,
'defaultsDeep': true,
'difference': true,
'matchesProperty': true,
'merge': true,
'random': true,
'range': true,
'rangeRight': true,
'zip': true,
'zipObject': true
}
};

View File

@@ -1,13 +0,0 @@
var baseConvert = require('./baseConvert.js');
/**
* Converts `lodash` to an auto-curried iteratee-first data-last version.
*
* @param {Function} lodash The lodash function.
* @returns {Function} Returns the converted lodash function.
*/
function browserConvert(lodash) {
return baseConvert(lodash, lodash);
}
module.exports = browserConvert;

View File

@@ -1,20 +1,15 @@
var _ = require('../lodash'),
baseConvert = require('./baseConvert.js'),
util = require('./util.js');
var baseConvert = require('./_baseConvert'),
util = require('./_util');
/**
* Converts `func` of `name` to an auto-curried iteratee-first data-last version.
* If `name` is an object, the methods on it will be converted and the object returned.
* Converts `func` of `name` to an immutable auto-curried iteratee-first data-last
* version. If `name` is an object its methods will be converted.
*
* @param {string} [name] The name of the function to wrap.
* @param {string} name The name of the function to wrap.
* @param {Function} [func] The function to wrap.
* @returns {Function|Object} Returns the converted function or object.
*/
function convert() {
var args = arguments,
name = args.length ? args[0] : _.noConflict().runInContext(),
func = args[1];
function convert(name, func) {
return baseConvert(util, name, func);
}

View File

@@ -1,16 +0,0 @@
var baseConvert = require('./baseConvert.js'),
util = require('./util.js');
/**
* Converts `func` of `name` to an auto-curried iteratee-first data-last version.
* If `name` is an object, the methods on it will be converted and the object returned.
*
* @param {string} name The name of the function to wrap.
* @param {Function} func The function to wrap.
* @returns {Function|Object} Returns the converted function or object.
*/
function nodeConvert(name, func) {
return baseConvert(util, name, func);
}
module.exports = nodeConvert;

View File

@@ -1,164 +0,0 @@
module.exports = {
/** Used to map method names to their aliases. */
'aliasMap': {
'ary': ['nAry'],
'overEvery': ['allPass'],
'overSome': ['somePass'],
'filter': ['whereEq'],
'flatten': ['unnest'],
'flow': ['pipe'],
'flowRight': ['compose'],
'forEach': ['each'],
'forEachRight': ['eachRight'],
'get': ['path'],
'getOr': ['pathOr'],
'head': ['first'],
'includes': ['contains'],
'initial': ['init'],
'isEqual': ['equals'],
'mapValues': ['mapObj'],
'matchesProperty': ['pathEq'],
'overArgs': ['useWith'],
'omit': ['dissoc', 'omitAll'],
'pick': ['pickAll'],
'property': ['prop'],
'propertyOf': ['propOf'],
'rest': ['unapply'],
'some': ['all'],
'spread': ['apply'],
'zipObject': ['zipObj']
},
/** Used to map method names to their iteratee ary. */
'aryIterateeMap': {
'assignWith': 2,
'cloneDeepWith': 1,
'cloneWith': 1,
'dropRightWhile': 1,
'dropWhile': 1,
'every': 1,
'extendWith': 2,
'filter': 1,
'find': 1,
'findIndex': 1,
'findKey': 1,
'findLast': 1,
'findLastIndex': 1,
'findLastKey': 1,
'flatMap': 1,
'forEach': 1,
'forEachRight': 1,
'forIn': 1,
'forInRight': 1,
'forOwn': 1,
'forOwnRight': 1,
'isEqualWith': 2,
'isMatchWith': 2,
'map': 1,
'mapKeys': 1,
'mapValues': 1,
'partition': 1,
'reduce': 2,
'reduceRight': 2,
'reject': 1,
'remove': 1,
'some': 1,
'takeRightWhile': 1,
'takeWhile': 1,
'times': 1,
'transform': 2
},
/** Used to map ary to method names. */
'aryMethodMap': {
1: (
'attempt,ceil,create,curry,curryRight,floor,fromPairs,iteratee,invert,over,' +
'overEvery,overSome,memoize,method,methodOf,mixin,rest,reverse,round,' +
'runInContext,template,trim,trimLeft,trimRight,uniqueId,words').split(','),
2: (
'add,ary,assign,at,bind,bindKey,cloneDeepWith,cloneWith,concat,countBy,curryN,' +
'curryRightN,debounce,defaults,defaultsDeep,delay,difference,drop,dropRight,' +
'dropRightWhile,dropWhile,endsWith,eq,every,extend,filter,find,find,findIndex,' +
'findKey,findLast,findLastIndex,findLastKey,flatMap,forEach,forEachRight,' +
'forIn,forInRight,forOwn,forOwnRight,get,groupBy,includes,indexBy,indexOf,' +
'intersection,invoke,invokeMap,isMatch,lastIndexOf,map,mapKeys,mapValues,' +
'matchesProperty,maxBy,mean,minBy,merge,omit,orderBy,overArgs,pad,padLeft,' +
'padRight,parseInt,partition,pick,pull,pullAll,pullAt,random,range,rangeRight,' +
'rearg,reject,remove,repeat,result,sampleSize,some,sortBy,sortedIndexBy,' +
'sortedLastIndexBy,sortedUniqBy,startsWith,subtract,sumBy,take,takeRight,' +
'takeRightWhile,takeWhile,throttle,times,truncate,union,uniqBy,without,wrap,' +
'xor,zip,zipObject').split(','),
3: (
'assignWith,clamp,differenceBy,extendWith,getOr,inRange,intersectionBy,' +
'isEqualWith,isMatchWith,mergeWith,omitBy,pickBy,pullAllBy,reduce,' +
'reduceRight,set,slice,transform,unionBy,xorBy,zipWith').split(','),
4:
['fill', 'setWith']
},
/** Used to map ary to rearg configs by method ary. */
'aryReargMap': {
2: [1, 0],
3: [2, 1, 0],
4: [3, 2, 0, 1]
},
/** Used to map ary to rearg configs by method names. */
'methodReargMap': {
'clamp': [2, 0, 1],
'reduce': [2, 0, 1],
'reduceRight': [2, 0, 1],
'setWith': [3, 2, 1, 0],
'slice': [2, 0, 1],
'transform': [2, 0, 1]
},
/** Used to iterate `mapping.aryMethodMap` keys. */
'caps': [1, 2, 3, 4],
/** Used to map keys to other keys. */
'keyMap': {
'curryN': 'curry',
'curryRightN': 'curryRight',
'getOr': 'get'
},
/** Used to identify methods which mutate arrays or objects. */
'mutateMap': {
'array': {
'fill': true,
'pull': true,
'pullAll': true,
'pullAllBy': true,
'pullAt': true,
'remove': true,
'reverse': true
},
'object': {
'assign': true,
'assignWith': true,
'defaults': true,
'defaultsDeep': true,
'extend': true,
'extendWith': true,
'merge': true,
'mergeWith': true
},
'set': {
'set': true,
'setWith': true
}
},
/** Used to track methods that skip `_.rearg`. */
'skipReargMap': {
'difference': true,
'matchesProperty': true,
'random': true,
'range': true,
'rangeRight': true,
'zip': true,
'zipObject': true
}
};

View File

@@ -1,5 +1,3 @@
var baseSet = require('./internal/baseSet');
/**
* The inverse of `_.toPairs`; this method returns an object composed
* from key-value `pairs`.
@@ -21,7 +19,7 @@ function fromPairs(pairs) {
while (++index < length) {
var pair = pairs[index];
baseSet(result, pair[0], pair[1]);
result[pair[0]] = pair[1];
}
return result;
}

View File

@@ -9,14 +9,14 @@ var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is an array of the elements responsible for generating the key.
* of each key is an array of elements responsible for generating the key.
* The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*

4
internal/Symbol.js Normal file
View File

@@ -0,0 +1,4 @@
/** Built-in value references. */
var Symbol = global.Symbol;
module.exports = Symbol;

View File

@@ -1,4 +0,0 @@
/** Built-in value references. */
var _Symbol = global.Symbol;
module.exports = _Symbol;

View File

@@ -6,14 +6,14 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initFromArray) {
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array.length;
if (initFromArray && length) {
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {

View File

@@ -6,12 +6,12 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initFromArray] Specify using the last element of `array` as the initial value.
* @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array.length;
if (initFromArray && length) {
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {

View File

@@ -1,7 +1,7 @@
/**
* The base implementation of methods like `_.find` and `_.findKey`, without
* support for iteratee shorthands, which iterates over `collection` using
* the provided `eachFunc`.
* `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to search.

View File

@@ -8,7 +8,6 @@ var apply = require('./apply'),
* The base implementation of `_.invoke` without support for individual
* method arguments.
*
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.

View File

@@ -47,7 +47,10 @@ function baseIsMatch(object, source, matchData, customizer) {
var stack = new Stack,
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
if (!(result === undefined
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
: result
)) {
return false;
}
}

View File

@@ -13,10 +13,11 @@ var Stack = require('./Stack'),
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
*/
function baseMerge(object, source, customizer, stack) {
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
@@ -28,7 +29,7 @@ function baseMerge(object, source, customizer, stack) {
}
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, baseMerge, customizer, stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;

View File

@@ -19,11 +19,12 @@ var assignMergeValue = require('./assignMergeValue'),
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
*/
function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) {
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = object[key],
srcValue = source[key],
stacked = stack.get(srcValue) || stack.get(objValue);
@@ -38,24 +39,36 @@ function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) {
if (isCommon) {
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
newValue = isArray(objValue)
? objValue
: ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue));
if (isArray(objValue)) {
newValue = srcIndex ? copyArray(objValue) : objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
newValue = baseClone(srcValue);
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = isArguments(objValue)
? toPlainObject(objValue)
: (isObject(objValue) ? objValue : baseClone(srcValue));
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = baseClone(srcValue);
}
else {
newValue = srcIndex ? baseClone(objValue) : objValue;
}
}
else {
isCommon = isFunction(srcValue);
isCommon = false;
}
}
stack.set(srcValue, newValue);
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
mergeFunc(newValue, srcValue, customizer, stack);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
}
assignMergeValue(object, key, newValue);
}

View File

@@ -11,7 +11,7 @@ var baseForIn = require('./baseForIn');
function basePickBy(object, predicate) {
var result = {};
baseForIn(object, function(value, key) {
if (predicate(value)) {
if (predicate(value, key)) {
result[key] = value;
}
});

View File

@@ -1,20 +1,19 @@
/**
* The base implementation of `_.reduce` and `_.reduceRight`, without support
* for iteratee shorthands, which iterates over `collection` using the provided
* `eachFunc`.
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} accumulator The initial value.
* @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value.
* @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the accumulated value.
*/
function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
eachFunc(collection, function(value, index, collection) {
accumulator = initFromCollection
? (initFromCollection = false, value)
accumulator = initAccum
? (initAccum = false, value)
: iteratee(accumulator, value, index, collection);
});
return accumulator;

View File

@@ -1,8 +1,8 @@
var _Symbol = require('./_Symbol');
var Symbol = require('./Symbol');
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf = _Symbol ? symbolProto.valueOf : undefined;
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
/**
* Creates a clone of the `symbol` object.
@@ -12,7 +12,7 @@ var symbolProto = _Symbol ? _Symbol.prototype : undefined,
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return _Symbol ? Object(symbolValueOf.call(symbol)) : {};
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
}
module.exports = cloneSymbol;

View File

@@ -24,7 +24,7 @@ function createAssigner(assigner) {
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, customizer);
assigner(object, source, index, customizer);
}
}
return object;

View File

@@ -3,14 +3,15 @@ var stringToArray = require('./stringToArray'),
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Creates a function like `_.lowerFirst`.

View File

@@ -5,14 +5,15 @@ var repeat = require('../repeat'),
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;

View File

@@ -1,5 +1,5 @@
var Uint8Array = require('./Uint8Array'),
_Symbol = require('./_Symbol'),
var Symbol = require('./Symbol'),
Uint8Array = require('./Uint8Array'),
mapToArray = require('./mapToArray'),
setToArray = require('./setToArray');
@@ -21,8 +21,8 @@ var boolTag = '[object Boolean]',
var arrayBufferTag = '[object ArrayBuffer]';
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf = _Symbol ? symbolProto.valueOf : undefined;
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined;
/**
* A specialized version of `baseIsEqualDeep` for comparing objects of
@@ -80,7 +80,7 @@ function equalByTag(object, other, tag, equalFunc, customizer, bitmask) {
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
case symbolTag:
return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
}
return false;
}

View File

@@ -2,8 +2,7 @@ var baseHas = require('./baseHas'),
keys = require('../keys');
/** Used to compose bitmasks for comparison styles. */
var UNORDERED_COMPARE_FLAG = 1,
PARTIAL_COMPARE_FLAG = 2;
var PARTIAL_COMPARE_FLAG = 2;
/**
* A specialized version of `baseIsEqualDeep` for objects with support for
@@ -20,7 +19,6 @@ var UNORDERED_COMPARE_FLAG = 1,
*/
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
objProps = keys(object),
objLength = objProps.length,
othProps = keys(other),
@@ -32,8 +30,7 @@ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
var index = objLength;
while (index--) {
var key = objProps[index];
if (!(isPartial ? key in other : baseHas(other, key)) ||
!(isUnordered || key == othProps[index])) {
if (!(isPartial ? key in other : baseHas(other, key))) {
return false;
}
}

View File

@@ -1,5 +1,11 @@
var realNames = require('./realNames');
/** Used for built-in method references. */
var objectProto = global.Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Gets the name of `func`.
*
@@ -10,7 +16,7 @@ var realNames = require('./realNames');
function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = array ? array.length : 0;
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],

View File

@@ -1,5 +1,4 @@
var baseClone = require('./baseClone'),
baseMerge = require('./baseMerge'),
var baseMerge = require('./baseMerge'),
isObject = require('../isObject');
/**
@@ -17,9 +16,9 @@ var baseClone = require('./baseClone'),
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) {
stack.set(srcValue, objValue);
baseMerge(objValue, srcValue, mergeDefaults, stack);
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
}
return objValue === undefined ? baseClone(srcValue) : objValue;
return objValue;
}
module.exports = mergeDefaults;

View File

@@ -1,12 +1,14 @@
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']',
rsCombo = '[' + rsComboRange + ']',
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
@@ -20,14 +22,15 @@ var reOptMod = rsModifier + '?',
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g');
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Gets the number of symbols in `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the string size.
*/

View File

@@ -1,12 +1,14 @@
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']',
rsCombo = '[' + rsComboRange + ']',
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
@@ -20,7 +22,7 @@ var reOptMod = rsModifier + '?',
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g');
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/**
* Converts `string` to an array.

View File

@@ -14,6 +14,7 @@ var arrayMap = require('./internal/arrayMap'),
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values.
* @example
*
* _.intersection([2, 1], [4, 2], [1, 2]);
* // => [2]
*/

View File

@@ -3,7 +3,7 @@ var baseIsEqual = require('./internal/baseIsEqual');
/**
* This method is like `_.isEqual` except that it accepts `customizer` which is
* invoked to compare values. If `customizer` returns `undefined` comparisons are
* handled by the method instead. The `customizer` is invoked with up to seven arguments:
* handled by the method instead. The `customizer` is invoked with up to six arguments:
* (objValue, othValue [, index|key, object, other, stack]).
*
* @static

View File

@@ -4,7 +4,7 @@ var baseIsMatch = require('./internal/baseIsMatch'),
/**
* This method is like `_.isMatch` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined` comparisons
* are handled by the method instead. The `customizer` is invoked with three
* are handled by the method instead. The `customizer` is invoked with five
* arguments: (objValue, srcValue, index|key, object, source).
*
* @static

View File

@@ -10,7 +10,7 @@ var createAggregator = require('./internal/createAggregator');
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -19,13 +19,13 @@ var createAggregator = require('./internal/createAggregator');
* { 'dir': 'right', 'code': 100 }
* ];
*
* _.keyBy(keyData, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*
* _.keyBy(keyData, function(o) {
* return String.fromCharCode(o.code);
* });
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*
* _.keyBy(keyData, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyBy = createAggregator(function(result, value, key) {
result[key] = value;

276
lodash.js
View File

@@ -1,6 +1,6 @@
/**
* @license
* lodash 4.0.0 (Custom Build) <https://lodash.com/>
* lodash 4.0.1 (Custom Build) <https://lodash.com/>
* Build: `lodash -d -o ./lodash.js`
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
var VERSION = '4.0.0';
var VERSION = '4.0.1';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -163,7 +163,8 @@
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
@@ -177,12 +178,13 @@
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']',
rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboRange + ']',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
@@ -199,14 +201,17 @@
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
/** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo, 'g');
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g');
var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/** Used to match non-compound words composed of alphanumeric characters. */
var reBasicWord = /[a-zA-Z0-9]+/g;
@@ -216,7 +221,8 @@
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+',
rsDigits + '(?:' + rsLowerMisc + '+)?',
rsUpper + '+',
rsDigits,
rsEmoji
].join('|'), 'g');
@@ -597,14 +603,14 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initFromArray) {
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array.length;
if (initFromArray && length) {
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
@@ -621,12 +627,12 @@
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initFromArray] Specify using the last element of `array` as the initial value.
* @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
var length = array.length;
if (initFromArray && length) {
if (initAccum && length) {
accumulator = array[--length];
}
while (length--) {
@@ -688,7 +694,7 @@
/**
* The base implementation of methods like `_.find` and `_.findKey`, without
* support for iteratee shorthands, which iterates over `collection` using
* the provided `eachFunc`.
* `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to search.
@@ -756,21 +762,20 @@
/**
* The base implementation of `_.reduce` and `_.reduceRight`, without support
* for iteratee shorthands, which iterates over `collection` using the provided
* `eachFunc`.
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} accumulator The initial value.
* @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value.
* @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the accumulated value.
*/
function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
eachFunc(collection, function(value, index, collection) {
accumulator = initFromCollection
? (initFromCollection = false, value)
accumulator = initAccum
? (initAccum = false, value)
: iteratee(accumulator, value, index, collection);
});
return accumulator;
@@ -1164,6 +1169,7 @@
/**
* Gets the number of symbols in `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the string size.
*/
@@ -1279,14 +1285,14 @@
);
/** Built-in value references. */
var _Symbol = context.Symbol,
Reflect = context.Reflect,
var Reflect = context.Reflect,
Symbol = context.Symbol,
Uint8Array = context.Uint8Array,
clearTimeout = context.clearTimeout,
enumerate = Reflect ? Reflect.enumerate : undefined,
getPrototypeOf = Object.getPrototypeOf,
getOwnPropertySymbols = Object.getOwnPropertySymbols,
iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
setTimeout = context.setTimeout,
splice = arrayProto.splice;
@@ -1317,9 +1323,9 @@
setCtorString = Set ? funcToString.call(Set) : '';
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf = _Symbol ? symbolProto.valueOf : undefined,
symbolToString = _Symbol ? symbolProto.toString : undefined;
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined,
symbolToString = Symbol ? symbolProto.toString : undefined;
/** Used to lookup unminified function names. */
var realNames = {};
@@ -1367,13 +1373,12 @@
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
* `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
* `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
* `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap`,
* `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
* `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invokeMap`,
* `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`,
* `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`,
* `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`,
@@ -1392,22 +1397,23 @@
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
* `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`,
* `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`,
* `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`,
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
* `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`,
* `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
* `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
* `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`,
* `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`,
* `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, `padEnd`,
* `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`,
* `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase`,
* `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`,
* `startCase`, `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times`,
* `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`,
* `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`,
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
* `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
* `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`,
* `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
* `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`,
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`,
* `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`,
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
* `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`,
* `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`,
* `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
* `upperCase`, `upperFirst`, `value`, and `words`
*
* @name _
@@ -2667,7 +2673,6 @@
* The base implementation of `_.invoke` without support for individual
* method arguments.
*
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the method to invoke.
@@ -2810,7 +2815,10 @@
var stack = new Stack,
result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined;
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) {
if (!(result === undefined
? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
: result
)) {
return false;
}
}
@@ -2946,10 +2954,11 @@
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
*/
function baseMerge(object, source, customizer, stack) {
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
@@ -2961,7 +2970,7 @@
}
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, baseMerge, customizer, stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
@@ -2982,11 +2991,12 @@
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
*/
function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) {
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = object[key],
srcValue = source[key],
stacked = stack.get(srcValue) || stack.get(objValue);
@@ -3001,24 +3011,36 @@
if (isCommon) {
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
newValue = isArray(objValue)
? objValue
: ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue));
if (isArray(objValue)) {
newValue = srcIndex ? copyArray(objValue) : objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
newValue = baseClone(srcValue);
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = isArguments(objValue)
? toPlainObject(objValue)
: (isObject(objValue) ? objValue : baseClone(srcValue));
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
newValue = baseClone(srcValue);
}
else {
newValue = srcIndex ? baseClone(objValue) : objValue;
}
}
else {
isCommon = isFunction(srcValue);
isCommon = false;
}
}
stack.set(srcValue, newValue);
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
mergeFunc(newValue, srcValue, customizer, stack);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
}
assignMergeValue(object, key, newValue);
}
@@ -3082,7 +3104,7 @@
function basePickBy(object, predicate) {
var result = {};
baseForIn(object, function(value, key) {
if (predicate(value)) {
if (predicate(value, key)) {
result[key] = value;
}
});
@@ -3667,7 +3689,7 @@
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return _Symbol ? Object(symbolValueOf.call(symbol)) : {};
return Symbol ? Object(symbolValueOf.call(symbol)) : {};
}
/**
@@ -3870,7 +3892,7 @@
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, customizer);
assigner(object, source, index, customizer);
}
}
return object;
@@ -4555,7 +4577,7 @@
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
case symbolTag:
return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other));
}
return false;
}
@@ -4575,7 +4597,6 @@
*/
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
objProps = keys(object),
objLength = objProps.length,
othProps = keys(other),
@@ -4587,8 +4608,7 @@
var index = objLength;
while (index--) {
var key = objProps[index];
if (!(isPartial ? key in other : baseHas(other, key)) ||
!(isUnordered || key == othProps[index])) {
if (!(isPartial ? key in other : baseHas(other, key))) {
return false;
}
}
@@ -4658,7 +4678,7 @@
function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = array ? array.length : 0;
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],
@@ -5099,9 +5119,9 @@
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) {
stack.set(srcValue, objValue);
baseMerge(objValue, srcValue, mergeDefaults, stack);
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
}
return objValue === undefined ? baseClone(srcValue) : objValue;
return objValue;
}
/**
@@ -5315,8 +5335,11 @@
* // => [1]
*/
var concat = rest(function(array, values) {
if (!isArray(array)) {
array = array == null ? [] : [Object(array)];
}
values = baseFlatten(values);
return arrayConcat(isArray(array) ? array : [Object(array)], values);
return arrayConcat(array, values);
});
/**
@@ -5748,7 +5771,7 @@
while (++index < length) {
var pair = pairs[index];
baseSet(result, pair[0], pair[1]);
result[pair[0]] = pair[1];
}
return result;
}
@@ -5837,6 +5860,7 @@
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values.
* @example
*
* _.intersection([2, 1], [4, 2], [1, 2]);
* // => [2]
*/
@@ -6029,7 +6053,7 @@
*
* var array = [1, 2, 3, 1, 2, 3];
*
* _.pull(array, [2, 3]);
* _.pullAll(array, [2, 3]);
* console.log(array);
* // => [1, 1]
*/
@@ -6153,6 +6177,7 @@
* **Note:** This method mutates `array` and is based on
* [`Array#reverse`](https://mdn.io/Array/reverse).
*
* @static
* @memberOf _
* @category Array
* @returns {Array} Returns `array`.
@@ -7111,7 +7136,7 @@
/**
* This method is the wrapper version of `_.flatMap`.
*
* @static
* @name flatMap
* @memberOf _
* @category Seq
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
@@ -7262,7 +7287,7 @@
*
* @name value
* @memberOf _
* @alias run, toJSON, valueOf
* @alias toJSON, valueOf
* @category Seq
* @returns {*} Returns the resolved unwrapped value.
* @example
@@ -7286,7 +7311,7 @@
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -7510,14 +7535,14 @@
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is an array of the elements responsible for generating the key.
* of each key is an array of elements responsible for generating the key.
* The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -7622,7 +7647,7 @@
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -7631,13 +7656,13 @@
* { 'dir': 'right', 'code': 100 }
* ];
*
* _.keyBy(keyData, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*
* _.keyBy(keyData, function(o) {
* return String.fromCharCode(o.code);
* });
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*
* _.keyBy(keyData, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyBy = createAggregator(function(result, value, key) {
result[key] = value;
@@ -7669,11 +7694,11 @@
* return n * n;
* }
*
* _.map([1, 2], square);
* // => [3, 6]
* _.map([4, 8], square);
* // => [16, 64]
*
* _.map({ 'a': 1, 'b': 2 }, square);
* // => [3, 6] (iteration order is not guaranteed)
* _.map({ 'a': 4, 'b': 8 }, square);
* // => [16, 64] (iteration order is not guaranteed)
*
* var users = [
* { 'user': 'barney' },
@@ -7732,9 +7757,9 @@
/**
* Creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, while the second of which
* contains elements `predicate` returns falsey for. The predicate is invoked
* with three arguments: (value, index|key, collection).
* contains elements `predicate` returns truthy for, the second of which
* contains elements `predicate` returns falsey for. The predicate is
* invoked with one argument: (value).
*
* @static
* @memberOf _
@@ -7806,9 +7831,9 @@
*/
function reduce(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduce : baseReduce,
initFromCollection = arguments.length < 3;
initAccum = arguments.length < 3;
return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEach);
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
}
/**
@@ -7833,9 +7858,9 @@
*/
function reduceRight(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduceRight : baseReduce,
initFromCollection = arguments.length < 3;
initAccum = arguments.length < 3;
return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight);
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
}
/**
@@ -7899,7 +7924,8 @@
}
/**
* Gets `n` random elements from `collection`.
* Gets `n` random elements at unique keys from `collection` up to the
* size of `collection`.
*
* @static
* @memberOf _
@@ -7909,8 +7935,11 @@
* @returns {Array} Returns the random elements.
* @example
*
* _.sampleSize([1, 2, 3, 4], 2);
* _.sampleSize([1, 2, 3], 2);
* // => [3, 1]
*
* _.sampleSize([1, 2, 3], 4);
* // => [2, 3, 1]
*/
function sampleSize(collection, n) {
var index = -1,
@@ -9074,7 +9103,7 @@
* This method is like `_.clone` except that it accepts `customizer` which
* is invoked to produce the cloned value. If `customizer` returns `undefined`
* cloning is handled by the method instead. The `customizer` is invoked with
* up to five arguments; (value [, index|key, object, stack]).
* up to four arguments; (value [, index|key, object, stack]).
*
* @static
* @memberOf _
@@ -9090,7 +9119,7 @@
* }
* }
*
* var el = _.clone(document.body, customizer);
* var el = _.cloneWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false
@@ -9140,7 +9169,7 @@
* }
* }
*
* var el = _.cloneDeep(document.body, customizer);
* var el = _.cloneDeepWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false
@@ -9468,7 +9497,7 @@
/**
* This method is like `_.isEqual` except that it accepts `customizer` which is
* invoked to compare values. If `customizer` returns `undefined` comparisons are
* handled by the method instead. The `customizer` is invoked with up to seven arguments:
* handled by the method instead. The `customizer` is invoked with up to six arguments:
* (objValue, othValue [, index|key, object, other, stack]).
*
* @static
@@ -9718,7 +9747,7 @@
/**
* This method is like `_.isMatch` except that it accepts `customizer` which
* is invoked to compare values. If `customizer` returns `undefined` comparisons
* are handled by the method instead. The `customizer` is invoked with three
* are handled by the method instead. The `customizer` is invoked with five
* arguments: (objValue, srcValue, index|key, object, source).
*
* @static
@@ -10189,7 +10218,7 @@
* @memberOf _
* @category Lang
* @param {*} value The value to convert.
* @return {number} Returns the converted integer.
* @returns {number} Returns the converted integer.
* @example
*
* _.toLength(3);
@@ -10328,7 +10357,7 @@
return '';
}
if (isSymbol(value)) {
return _Symbol ? symbolToString.call(value) : '';
return Symbol ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
@@ -10430,7 +10459,7 @@
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, customizer) {
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keysIn(source), object, customizer);
});
@@ -10460,7 +10489,7 @@
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, customizer) {
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
copyObjectWith(source, keys(source), object, customizer);
});
@@ -11140,8 +11169,8 @@
* _.merge(users, ages);
* // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
*/
var merge = createAssigner(function(object, source) {
baseMerge(object, source);
var merge = createAssigner(function(object, source, srcIndex) {
baseMerge(object, source, srcIndex);
});
/**
@@ -11179,8 +11208,8 @@
* _.mergeWith(object, other, customizer);
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
*/
var mergeWith = createAssigner(function(object, source, customizer) {
baseMerge(object, source, customizer);
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
baseMerge(object, source, srcIndex, customizer);
});
/**
@@ -11228,9 +11257,9 @@
* // => { 'b': '2' }
*/
function omitBy(object, predicate) {
predicate = getIteratee(predicate);
return basePickBy(object, function(value) {
return !predicate(value);
predicate = getIteratee(predicate, 2);
return basePickBy(object, function(value, key) {
return !predicate(value, key);
});
}
@@ -11273,7 +11302,7 @@
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
return object == null ? {} : basePickBy(object, getIteratee(predicate));
return object == null ? {} : basePickBy(object, getIteratee(predicate, 2));
}
/**
@@ -12040,7 +12069,7 @@
* `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
* in which case a `radix` of `16` is used.
*
* **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E)
* **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2)
* of `parseInt`.
*
* @static
@@ -12832,7 +12861,7 @@
* [_.matches({ 'a': 1 }), _.constant('matches A')],
* [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
* [_.constant(true), _.constant('no match')]
* ])
* ]);
*
* func({ 'a': 1, 'b': 2 });
* // => 'matches A'
@@ -13203,7 +13232,9 @@
* var lodash = _.noConflict();
*/
function noConflict() {
root._ = oldDash;
if (root._ === this) {
root._ = oldDash;
}
return this;
}
@@ -13368,8 +13399,7 @@
* Creates an array of numbers (positive and/or negative) progressing from
* `start` up to, but not including, `end`. A step of `-1` is used if a negative
* `start` is specified without an `end` or `step`. If `end` is not specified
* it's set to `start` with `start` then set to `0`. If `end` is less than
* `start` a zero-length range is created unless a negative `step` is specified.
* it's set to `start` with `start` then set to `0`.
*
* **Note:** JavaScript follows the IEEE-754 standard for resolving
* floating-point values which can produce unexpected results.
@@ -13637,7 +13667,7 @@
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.maxBy(objects, function(o) { return o.a; });
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
* // using the `_.property` iteratee shorthand
@@ -13705,7 +13735,7 @@
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.minBy(objects, function(o) { return o.a; });
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* // using the `_.property` iteratee shorthand
@@ -13989,8 +14019,6 @@
lodash.zipWith = zipWith;
// Add aliases.
lodash.each = forEach;
lodash.eachRight = forEachRight;
lodash.extend = assignIn;
lodash.extendWith = assignInWith;
@@ -14133,6 +14161,8 @@
lodash.upperFirst = upperFirst;
// Add aliases.
lodash.each = forEach;
lodash.eachRight = forEachRight;
lodash.first = head;
mixin(lodash, (function() {

8
map.js
View File

@@ -29,11 +29,11 @@ var arrayMap = require('./internal/arrayMap'),
* return n * n;
* }
*
* _.map([1, 2], square);
* // => [3, 6]
* _.map([4, 8], square);
* // => [16, 64]
*
* _.map({ 'a': 1, 'b': 2 }, square);
* // => [3, 6] (iteration order is not guaranteed)
* _.map({ 'a': 4, 'b': 8 }, square);
* // => [16, 64] (iteration order is not guaranteed)
*
* var users = [
* { 'user': 'barney' },

View File

@@ -17,7 +17,7 @@ var baseExtremum = require('./internal/baseExtremum'),
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.maxBy(objects, function(o) { return o.a; });
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
* // using the `_.property` iteratee shorthand

View File

@@ -30,8 +30,8 @@ var baseMerge = require('./internal/baseMerge'),
* _.merge(users, ages);
* // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
*/
var merge = createAssigner(function(object, source) {
baseMerge(object, source);
var merge = createAssigner(function(object, source, srcIndex) {
baseMerge(object, source, srcIndex);
});
module.exports = merge;

View File

@@ -36,8 +36,8 @@ var baseMerge = require('./internal/baseMerge'),
* _.mergeWith(object, other, customizer);
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
*/
var mergeWith = createAssigner(function(object, source, customizer) {
baseMerge(object, source, customizer);
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
baseMerge(object, source, srcIndex, customizer);
});
module.exports = mergeWith;

View File

@@ -17,7 +17,7 @@ var baseExtremum = require('./internal/baseExtremum'),
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.minBy(objects, function(o) { return o.a; });
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* // using the `_.property` iteratee shorthand

View File

@@ -6,6 +6,8 @@ module.exports = {
'create': require('./create'),
'defaults': require('./defaults'),
'defaultsDeep': require('./defaultsDeep'),
'extend': require('./extend'),
'extendWith': require('./extendWith'),
'findKey': require('./findKey'),
'findLastKey': require('./findLastKey'),
'forIn': require('./forIn'),

View File

@@ -20,9 +20,9 @@ var baseIteratee = require('./internal/baseIteratee'),
* // => { 'b': '2' }
*/
function omitBy(object, predicate) {
predicate = baseIteratee(predicate);
return basePickBy(object, function(value) {
return !predicate(value);
predicate = baseIteratee(predicate, 2);
return basePickBy(object, function(value, key) {
return !predicate(value, key);
});
}

View File

@@ -1,11 +1,11 @@
{
"name": "lodash",
"version": "4.0.0",
"version": "4.0.1",
"description": "Lodash modular utilities.",
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",
"license": "MIT",
"main": "index.js",
"main": "lodash.js",
"keywords": "modules, stdlib, util",
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
"contributors": [

View File

@@ -14,7 +14,7 @@ var nativeParseInt = global.parseInt;
* `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
* in which case a `radix` of `16` is used.
*
* **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E)
* **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2)
* of `parseInt`.
*
* @static

View File

@@ -2,9 +2,9 @@ var createAggregator = require('./internal/createAggregator');
/**
* Creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, while the second of which
* contains elements `predicate` returns falsey for. The predicate is invoked
* with three arguments: (value, index|key, collection).
* contains elements `predicate` returns truthy for, the second of which
* contains elements `predicate` returns falsey for. The predicate is
* invoked with one argument: (value).
*
* @static
* @memberOf _

View File

@@ -19,7 +19,7 @@ var baseIteratee = require('./internal/baseIteratee'),
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
return object == null ? {} : basePickBy(object, baseIteratee(predicate));
return object == null ? {} : basePickBy(object, baseIteratee(predicate, 2));
}
module.exports = pickBy;

View File

@@ -15,7 +15,7 @@ var basePullAll = require('./internal/basePullAll');
*
* var array = [1, 2, 3, 1, 2, 3];
*
* _.pull(array, [2, 3]);
* _.pullAll(array, [2, 3]);
* console.log(array);
* // => [1, 1]
*/

View File

@@ -4,8 +4,7 @@ var createRange = require('./internal/createRange');
* Creates an array of numbers (positive and/or negative) progressing from
* `start` up to, but not including, `end`. A step of `-1` is used if a negative
* `start` is specified without an `end` or `step`. If `end` is not specified
* it's set to `start` with `start` then set to `0`. If `end` is less than
* `start` a zero-length range is created unless a negative `step` is specified.
* it's set to `start` with `start` then set to `0`.
*
* **Note:** JavaScript follows the IEEE-754 standard for resolving
* floating-point values which can produce unexpected results.

View File

@@ -41,9 +41,9 @@ var arrayReduce = require('./internal/arrayReduce'),
*/
function reduce(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduce : baseReduce,
initFromCollection = arguments.length < 3;
initAccum = arguments.length < 3;
return func(collection, baseIteratee(iteratee, 4), accumulator, initFromCollection, baseEach);
return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach);
}
module.exports = reduce;

View File

@@ -26,9 +26,9 @@ var arrayReduceRight = require('./internal/arrayReduceRight'),
*/
function reduceRight(collection, iteratee, accumulator) {
var func = isArray(collection) ? arrayReduceRight : baseReduce,
initFromCollection = arguments.length < 3;
initAccum = arguments.length < 3;
return func(collection, baseIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight);
return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
}
module.exports = reduceRight;

View File

@@ -11,6 +11,7 @@ var nativeReverse = arrayProto.reverse;
* **Note:** This method mutates `array` and is based on
* [`Array#reverse`](https://mdn.io/Array/reverse).
*
* @static
* @memberOf _
* @category Array
* @returns {Array} Returns `array`.

View File

@@ -4,7 +4,8 @@ var baseClamp = require('./internal/baseClamp'),
toInteger = require('./toInteger');
/**
* Gets `n` random elements from `collection`.
* Gets `n` random elements at unique keys from `collection` up to the
* size of `collection`.
*
* @static
* @memberOf _
@@ -14,8 +15,11 @@ var baseClamp = require('./internal/baseClamp'),
* @returns {Array} Returns the random elements.
* @example
*
* _.sampleSize([1, 2, 3, 4], 2);
* _.sampleSize([1, 2, 3], 2);
* // => [3, 1]
*
* _.sampleSize([1, 2, 3], 4);
* // => [2, 3, 1]
*/
function sampleSize(collection, n) {
var index = -1,

View File

@@ -1,4 +1,4 @@
var _Symbol = require('./internal/_Symbol'),
var Symbol = require('./internal/Symbol'),
copyArray = require('./internal/copyArray'),
getTag = require('./internal/getTag'),
isArrayLike = require('./isArrayLike'),
@@ -14,7 +14,7 @@ var mapTag = '[object Map]',
setTag = '[object Set]';
/** Built-in value references. */
var iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined;
var iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined;
/**
* Converts `value` to an array.

View File

@@ -14,7 +14,7 @@ var MAX_ARRAY_LENGTH = 4294967295;
* @memberOf _
* @category Lang
* @param {*} value The value to convert.
* @return {number} Returns the converted integer.
* @returns {number} Returns the converted integer.
* @example
*
* _.toLength(3);

View File

@@ -1,12 +1,12 @@
var _Symbol = require('./internal/_Symbol'),
var Symbol = require('./internal/Symbol'),
isSymbol = require('./isSymbol');
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolToString = _Symbol ? symbolProto.toString : undefined;
var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolToString = Symbol ? symbolProto.toString : undefined;
/**
* Converts `value` to a string if it's not one. An empty string is returned
@@ -37,7 +37,7 @@ function toString(value) {
return '';
}
if (isSymbol(value)) {
return _Symbol ? symbolToString.call(value) : '';
return Symbol ? symbolToString.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;

View File

@@ -14,14 +14,15 @@ var reFlags = /\w*$/;
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
/**
* Truncates `string` if it's longer than the given maximum string length.

View File

@@ -2,6 +2,8 @@ var toString = require('./toString');
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
rsComboSymbolsRange = '\\u20d0-\\u20f0',
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
@@ -14,11 +16,13 @@ var rsAstralRange = '\\ud800-\\udfff',
/** Used to compose unicode capture groups. */
var rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
rsModifier = '(?:\\ud83c[\\udffb-\\udfff])',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
@@ -42,7 +46,8 @@ var reComplexWord = RegExp([
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
rsUpper + '?' + rsLowerMisc + '+',
rsDigits + '(?:' + rsLowerMisc + '+)?',
rsUpper + '+',
rsDigits,
rsEmoji
].join('|'), 'g');

View File

@@ -1,7 +1,7 @@
/**
* This method is the wrapper version of `_.flatMap`.
*
* @static
* @name flatMap
* @memberOf _
* @category Seq
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.

View File

@@ -52,13 +52,12 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
* `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
* `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
* `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
* `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
* `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
* `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap`,
* `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
* `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invokeMap`,
* `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`,
* `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`,
* `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`,
@@ -77,22 +76,23 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`,
* `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`,
* `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`,
* `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`,
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
* `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`,
* `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
* `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
* `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`,
* `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`,
* `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, `padEnd`,
* `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`,
* `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase`,
* `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`,
* `startCase`, `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times`,
* `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`,
* `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
* `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`,
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
* `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
* `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`,
* `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`,
* `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`,
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`,
* `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`,
* `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
* `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`,
* `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`,
* `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`,
* `upperCase`, `upperFirst`, `value`, and `words`
*
* @name _

View File

@@ -5,7 +5,7 @@ var baseWrapperValue = require('./internal/baseWrapperValue');
*
* @name value
* @memberOf _
* @alias run, toJSON, valueOf
* @alias toJSON, valueOf
* @category Seq
* @returns {*} Returns the resolved unwrapped value.
* @example