Comparing

lodash@4.17.0
npmjs.comunpkgBundlephobiaPackagephobia
...
lodash@4.17.21
npmjs.comunpkgBundlephobiaPackagephobia

Packagephobia

1.3 MB

1.3 MB

Publish

Install

Bundlephobia

npm diff

Options

files: **/!(*.map|*.min.js)

Showing 86 changed files with 1159 additions and 695 deletions
SplitUnified

package.json +++5---5

View file

@@ -1,6 +1,6 @@

1{1{
2 "name": "lodash",2 "name": "lodash",
3 "version": "4.17.0",3 "version": "4.17.21",
4 "description": "Lodash modular utilities.",4 "description": "Lodash modular utilities.",
5 "keywords": "modules, stdlib, util",5 "keywords": "modules, stdlib, util",
6 "homepage": "https://lodash.com/",6 "homepage": "https://lodash.com/",

@@ -8,10 +8,10 @@

8 "icon": "https://lodash.com/icon.svg",8 "icon": "https://lodash.com/icon.svg",
9 "license": "MIT",9 "license": "MIT",
10 "main": "lodash.js",10 "main": "lodash.js",
11 "author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",11 "author": "John-David Dalton <john.david.dalton@gmail.com>",
12 "contributors": [12 "contributors": [
13 "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
14 "Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"13 "John-David Dalton <john.david.dalton@gmail.com>",
14 "Mathias Bynens <mathias@qiwi.be>"
15 ],15 ],
16 "scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" }16 "scripts": { "test": "echo \"See https://travis-ci.org/lodash-archive/lodash-cli for testing details.\"" }
17}17}

README.md +++3---3

View file

@@ -1,4 +1,4 @@

1# lodash v4.17.01# lodash v4.17.21
2 2
3The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.3The [Lodash](https://lodash.com/) library exported as [Node.js](https://nodejs.org/) modules.
4 4

@@ -28,12 +28,12 @@

28var curryN = require('lodash/fp/curryN');28var curryN = require('lodash/fp/curryN');
29```29```
30 30
31See the [package source](https://github.com/lodash/lodash/tree/4.17.0-npm) for more details.31See the [package source](https://github.com/lodash/lodash/tree/4.17.21-npm) for more details.
32 32
33**Note:**<br>33**Note:**<br>
34Install [n_](https://www.npmjs.com/package/n_) for Lodash use in the Node.js < 6 REPL.34Install [n_](https://www.npmjs.com/package/n_) for Lodash use in the Node.js < 6 REPL.
35 35
36## Support36## Support
37 37
38Tested in Chrome 53-54, Firefox 48-49, IE 11, Edge 14, Safari 9-10, Node.js 6-7, & PhantomJS 2.1.1.<br>38Tested in Chrome 74-75, Firefox 66-67, IE 11, Edge 18, Safari 11-12, & Node.js 8-12.<br>
39Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.39Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available.

LICENSE +++1---1

View file

@@ -1,4 +1,4 @@

1Copyright JS Foundation and other contributors <https://js.foundation/>1Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
2 2
3Based on Underscore.js, copyright Jeremy Ashkenas,3Based on Underscore.js, copyright Jeremy Ashkenas,
4DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>4DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

core.js +++113---84

View file
Large diffs are not rendered by default.

_unicodeWords.js +++2---2

View file

@@ -38,8 +38,8 @@

38 reOptMod = rsModifier + '?',38 reOptMod = rsModifier + '?',
39 rsOptVar = '[' + rsVarRange + ']?',39 rsOptVar = '[' + rsVarRange + ']?',
40 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',40 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
41 rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
42 rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',41 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
42 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
43 rsSeq = rsOptVar + reOptMod + rsOptJoin,43 rsSeq = rsOptVar + reOptMod + rsOptJoin,
44 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;44 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
45 45

debounce.js +++5---2

View file

@@ -108,9 +108,11 @@

108 function remainingWait(time) {108 function remainingWait(time) {
109 var timeSinceLastCall = time - lastCallTime,109 var timeSinceLastCall = time - lastCallTime,
110 timeSinceLastInvoke = time - lastInvokeTime,110 timeSinceLastInvoke = time - lastInvokeTime,
111 result = wait - timeSinceLastCall;111 timeWaiting = wait - timeSinceLastCall;
112 112
113 return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;113 return maxing
114 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
115 : timeWaiting;
114 }116 }
115 117
116 function shouldInvoke(time) {118 function shouldInvoke(time) {

@@ -171,6 +173,7 @@

171 }173 }
172 if (maxing) {174 if (maxing) {
173 // Handle invocations in a tight loop.175 // Handle invocations in a tight loop.
176 clearTimeout(timerId);
174 timerId = setTimeout(timerExpired, wait);177 timerId = setTimeout(timerExpired, wait);
175 return invokeFunc(lastCallTime);178 return invokeFunc(lastCallTime);
176 }179 }

defaults.js +++39---7

View file

@@ -1,8 +1,14 @@

1var apply = require('./_apply'),
2 assignInDefaults = require('./_assignInDefaults'),
3 assignInWith = require('./assignInWith'),
4 baseRest = require('./_baseRest');1var baseRest = require('./_baseRest'),
2 eq = require('./eq'),
3 isIterateeCall = require('./_isIterateeCall'),
4 keysIn = require('./keysIn');
5 5
6/** Used for built-in method references. */
7var objectProto = Object.prototype;
8
9/** Used to check objects for own properties. */
10var hasOwnProperty = objectProto.hasOwnProperty;
11
6/**12/**
7 * Assigns own and inherited enumerable string keyed properties of source13 * Assigns own and inherited enumerable string keyed properties of source
8 * objects to the destination object for all destination properties that14 * objects to the destination object for all destination properties that

@@ -24,9 +30,35 @@

24 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });30 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
25 * // => { 'a': 1, 'b': 2 }31 * // => { 'a': 1, 'b': 2 }
26 */32 */
27var defaults = baseRest(function(args) {
28 args.push(undefined, assignInDefaults);
29 return apply(assignInWith, undefined, args);33var defaults = baseRest(function(object, sources) {
34 object = Object(object);
35
36 var index = -1;
37 var length = sources.length;
38 var guard = length > 2 ? sources[2] : undefined;
39
40 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
41 length = 1;
42 }
43
44 while (++index < length) {
45 var source = sources[index];
46 var props = keysIn(source);
47 var propsIndex = -1;
48 var propsLength = props.length;
49
50 while (++propsIndex < propsLength) {
51 var key = props[propsIndex];
52 var value = object[key];
53
54 if (value === undefined ||
55 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
56 object[key] = source[key];
57 }
58 }
59 }
60
61 return object;
30});62});
31 63
32module.exports = defaults;64module.exports = defaults;

_stringToPath.js +++5---9

View file

@@ -1,9 +1,7 @@

1var memoizeCapped = require('./_memoizeCapped'),
2 toString = require('./toString');1var memoizeCapped = require('./_memoizeCapped');
3 2
4/** Used to match property names within property paths. */3/** Used to match property names within property paths. */
5var reLeadingDot = /^\./,
6 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;4var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
7 5
8/** Used to match backslashes in property paths. */6/** Used to match backslashes in property paths. */
9var reEscapeChar = /\\(\\)?/g;7var reEscapeChar = /\\(\\)?/g;

@@ -16,14 +14,12 @@

16 * @returns {Array} Returns the property path array.14 * @returns {Array} Returns the property path array.
17 */15 */
18var stringToPath = memoizeCapped(function(string) {16var stringToPath = memoizeCapped(function(string) {
19 string = toString(string);
20
21 var result = [];17 var result = [];
22 if (reLeadingDot.test(string)) {18 if (string.charCodeAt(0) === 46 /* . */) {
23 result.push('');19 result.push('');
24 }20 }
25 string.replace(rePropName, function(match, number, quote, string) {
26 result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));21 string.replace(rePropName, function(match, number, quote, subString) {
22 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
27 });23 });
28 return result;24 return result;
29});25});

defaultsDeep.js +++2---2

View file

@@ -1,6 +1,6 @@

1var apply = require('./_apply'),1var apply = require('./_apply'),
2 baseRest = require('./_baseRest'),2 baseRest = require('./_baseRest'),
3 mergeDefaults = require('./_mergeDefaults'),3 customDefaultsMerge = require('./_customDefaultsMerge'),
4 mergeWith = require('./mergeWith');4 mergeWith = require('./mergeWith');
5 5
6/**6/**

@@ -23,7 +23,7 @@

23 * // => { 'a': { 'b': 2, 'c': 3 } }23 * // => { 'a': { 'b': 2, 'c': 3 } }
24 */24 */
25var defaultsDeep = baseRest(function(args) {25var defaultsDeep = baseRest(function(args) {
26 args.push(undefined, mergeDefaults);26 args.push(undefined, customDefaultsMerge);
27 return apply(mergeWith, undefined, args);27 return apply(mergeWith, undefined, args);
28});28});
29 29

filter.js +++4---0

View file

@@ -39,6 +39,10 @@

39 * // The `_.property` iteratee shorthand.39 * // The `_.property` iteratee shorthand.
40 * _.filter(users, 'active');40 * _.filter(users, 'active');
41 * // => objects for ['barney']41 * // => objects for ['barney']
42 *
43 * // Combining several predicates using `_.overEvery` or `_.overSome`.
44 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
45 * // => objects for ['fred', 'barney']
42 */46 */
43function filter(collection, predicate) {47function filter(collection, predicate) {
44 var func = isArray(collection) ? arrayFilter : baseFilter;48 var func = isArray(collection) ? arrayFilter : baseFilter;

_parent.js +++1---1

View file

@@ -10,7 +10,7 @@

10 * @returns {*} Returns the parent value.10 * @returns {*} Returns the parent value.
11 */11 */
12function parent(object, path) {12function parent(object, path) {
13 return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));13 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
14}14}
15 15
16module.exports = parent;16module.exports = parent;

_nodeUtil.js +++8---0

View file

@@ -15,6 +15,14 @@

15/** Used to access faster Node.js helpers. */15/** Used to access faster Node.js helpers. */
16var nodeUtil = (function() {16var nodeUtil = (function() {
17 try {17 try {
18 // Use `util.types` for Node.js 10+.
19 var types = freeModule && freeModule.require && freeModule.require('util').types;
20
21 if (types) {
22 return types;
23 }
24
25 // Legacy `process.binding('util')` for Node.js < 10.
18 return freeProcess && freeProcess.binding && freeProcess.binding('util');26 return freeProcess && freeProcess.binding && freeProcess.binding('util');
19 } catch (e) {}27 } catch (e) {}
20}());28}());

_mergeDefaults.js +++0---27

View file
This file was deleted.

_lazyValue.js +++1---5

View file

@@ -2,9 +2,6 @@

2 getView = require('./_getView'),2 getView = require('./_getView'),
3 isArray = require('./isArray');3 isArray = require('./isArray');
4 4
5/** Used as the size to enable large array optimizations. */
6var LARGE_ARRAY_SIZE = 200;
7
8/** Used to indicate the type of lazy iteratees. */5/** Used to indicate the type of lazy iteratees. */
9var LAZY_FILTER_FLAG = 1,6var LAZY_FILTER_FLAG = 1,
10 LAZY_MAP_FLAG = 2;7 LAZY_MAP_FLAG = 2;

@@ -36,8 +33,7 @@

36 resIndex = 0,33 resIndex = 0,
37 takeCount = nativeMin(length, this.__takeCount__);34 takeCount = nativeMin(length, this.__takeCount__);
38 35
39 if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
40 (arrLength == length && takeCount == length)) {36 if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
41 return baseWrapperValue(array, this.__actions__);37 return baseWrapperValue(array, this.__actions__);
42 }38 }
43 var result = [];39 var result = [];

_isIndex.js +++5---2

View file

@@ -13,10 +13,13 @@

13 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.13 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
14 */14 */
15function isIndex(value, length) {15function isIndex(value, length) {
16 var type = typeof value;
16 length = length == null ? MAX_SAFE_INTEGER : length;17 length = length == null ? MAX_SAFE_INTEGER : length;
18
17 return !!length &&19 return !!length &&
18 (typeof value == 'number' || reIsUint.test(value)) &&
19 (value > -1 && value % 1 == 0 && value < length);20 (type == 'number' ||
21 (type != 'symbol' && reIsUint.test(value))) &&
22 (value > -1 && value % 1 == 0 && value < length);
20}23}
21 24
22module.exports = isIndex;25module.exports = isIndex;

_initCloneByTag.js +++4---7

View file

@@ -1,8 +1,6 @@

1var cloneArrayBuffer = require('./_cloneArrayBuffer'),1var cloneArrayBuffer = require('./_cloneArrayBuffer'),
2 cloneDataView = require('./_cloneDataView'),2 cloneDataView = require('./_cloneDataView'),
3 cloneMap = require('./_cloneMap'),
4 cloneRegExp = require('./_cloneRegExp'),3 cloneRegExp = require('./_cloneRegExp'),
5 cloneSet = require('./_cloneSet'),
6 cloneSymbol = require('./_cloneSymbol'),4 cloneSymbol = require('./_cloneSymbol'),
7 cloneTypedArray = require('./_cloneTypedArray');5 cloneTypedArray = require('./_cloneTypedArray');
8 6

@@ -32,16 +30,15 @@

32 * Initializes an object clone based on its `toStringTag`.30 * Initializes an object clone based on its `toStringTag`.
33 *31 *
34 * **Note:** This function only supports cloning values with tags of32 * **Note:** This function only supports cloning values with tags of
35 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.33 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
36 *34 *
37 * @private35 * @private
38 * @param {Object} object The object to clone.36 * @param {Object} object The object to clone.
39 * @param {string} tag The `toStringTag` of the object to clone.37 * @param {string} tag The `toStringTag` of the object to clone.
40 * @param {Function} cloneFunc The function to clone values.
41 * @param {boolean} [isDeep] Specify a deep clone.38 * @param {boolean} [isDeep] Specify a deep clone.
42 * @returns {Object} Returns the initialized clone.39 * @returns {Object} Returns the initialized clone.
43 */40 */
44function initCloneByTag(object, tag, cloneFunc, isDeep) {41function initCloneByTag(object, tag, isDeep) {
45 var Ctor = object.constructor;42 var Ctor = object.constructor;
46 switch (tag) {43 switch (tag) {
47 case arrayBufferTag:44 case arrayBufferTag:

@@ -60,7 +57,7 @@

60 return cloneTypedArray(object, isDeep);57 return cloneTypedArray(object, isDeep);
61 58
62 case mapTag:59 case mapTag:
63 return cloneMap(object, isDeep, cloneFunc);60 return new Ctor;
64 61
65 case numberTag:62 case numberTag:
66 case stringTag:63 case stringTag:

@@ -70,7 +67,7 @@

70 return cloneRegExp(object);67 return cloneRegExp(object);
71 68
72 case setTag:69 case setTag:
73 return cloneSet(object, isDeep, cloneFunc);70 return new Ctor;
74 71
75 case symbolTag:72 case symbolTag:
76 return cloneSymbol(object);73 return cloneSymbol(object);

_initCloneArray.js +++1---1

View file

@@ -13,7 +13,7 @@

13 */13 */
14function initCloneArray(array) {14function initCloneArray(array) {
15 var length = array.length,15 var length = array.length,
16 result = array.constructor(length);16 result = new array.constructor(length);
17 17
18 // Add properties assigned by `RegExp#exec`.18 // Add properties assigned by `RegExp#exec`.
19 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {19 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {

_hashHas.js +++1---1

View file

@@ -17,7 +17,7 @@

17 */17 */
18function hashHas(key) {18function hashHas(key) {
19 var data = this.__data__;19 var data = this.__data__;
20 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);20 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
21}21}
22 22
23module.exports = hashHas;23module.exports = hashHas;

invert.js +++15---0

View file

@@ -2,7 +2,17 @@

2 createInverter = require('./_createInverter'),2 createInverter = require('./_createInverter'),
3 identity = require('./identity');3 identity = require('./identity');
4 4
5/** Used for built-in method references. */
6var objectProto = Object.prototype;
7
5/**8/**
9 * Used to resolve the
10 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11 * of values.
12 */
13var nativeObjectToString = objectProto.toString;
14
15/**
6 * Creates an object composed of the inverted keys and values of `object`.16 * Creates an object composed of the inverted keys and values of `object`.
7 * If `object` contains duplicate values, subsequent values overwrite17 * If `object` contains duplicate values, subsequent values overwrite
8 * property assignments of previous values.18 * property assignments of previous values.

@@ -21,6 +31,11 @@

21 * // => { '1': 'c', '2': 'b' }31 * // => { '1': 'c', '2': 'b' }
22 */32 */
23var invert = createInverter(function(result, value, key) {33var invert = createInverter(function(result, value, key) {
34 if (value != null &&
35 typeof value.toString != 'function') {
36 value = nativeObjectToString.call(value);
37 }
38
24 result[value] = key;39 result[value] = key;
25}, constant(identity));40}, constant(identity));
26 41

invertBy.js +++12---0

View file

@@ -8,6 +8,13 @@

8var hasOwnProperty = objectProto.hasOwnProperty;8var hasOwnProperty = objectProto.hasOwnProperty;
9 9
10/**10/**
11 * Used to resolve the
12 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
13 * of values.
14 */
15var nativeObjectToString = objectProto.toString;
16
17/**
11 * This method is like `_.invert` except that the inverted object is generated18 * This method is like `_.invert` except that the inverted object is generated
12 * from the results of running each element of `object` thru `iteratee`. The19 * from the results of running each element of `object` thru `iteratee`. The
13 * corresponding inverted value of each inverted key is an array of keys20 * corresponding inverted value of each inverted key is an array of keys

@@ -34,6 +41,11 @@

34 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }41 * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
35 */42 */
36var invertBy = createInverter(function(result, value, key) {43var invertBy = createInverter(function(result, value, key) {
44 if (value != null &&
45 typeof value.toString != 'function') {
46 value = nativeObjectToString.call(value);
47 }
48
37 if (hasOwnProperty.call(result, value)) {49 if (hasOwnProperty.call(result, value)) {
38 result[value].push(key);50 result[value].push(key);
39 } else {51 } else {

invokeMap.js +++2---5

View file

@@ -2,8 +2,7 @@

2 baseEach = require('./_baseEach'),2 baseEach = require('./_baseEach'),
3 baseInvoke = require('./_baseInvoke'),3 baseInvoke = require('./_baseInvoke'),
4 baseRest = require('./_baseRest'),4 baseRest = require('./_baseRest'),
5 isArrayLike = require('./isArrayLike'),
6 isKey = require('./_isKey');5 isArrayLike = require('./isArrayLike');
7 6
8/**7/**
9 * Invokes the method at `path` of each element in `collection`, returning8 * Invokes the method at `path` of each element in `collection`, returning

@@ -31,12 +30,10 @@

31var invokeMap = baseRest(function(collection, path, args) {30var invokeMap = baseRest(function(collection, path, args) {
32 var index = -1,31 var index = -1,
33 isFunc = typeof path == 'function',32 isFunc = typeof path == 'function',
34 isProp = isKey(path),
35 result = isArrayLike(collection) ? Array(collection.length) : [];33 result = isArrayLike(collection) ? Array(collection.length) : [];
36 34
37 baseEach(collection, function(value) {35 baseEach(collection, function(value) {
38 var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
39 result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);36 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
40 });37 });
41 return result;38 return result;
42});39});

_hasUnicodeWord.js +++1---1

View file

@@ -1,5 +1,5 @@

1/** Used to detect strings that need a more robust regexp to match words. */1/** Used to detect strings that need a more robust regexp to match words. */
2var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;2var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
3 3
4/**4/**
5 * Checks if `string` contains a word composed of Unicode symbols.5 * Checks if `string` contains a word composed of Unicode symbols.

_hasPath.js +++1---2

View file

@@ -2,7 +2,6 @@

2 isArguments = require('./isArguments'),2 isArguments = require('./isArguments'),
3 isArray = require('./isArray'),3 isArray = require('./isArray'),
4 isIndex = require('./_isIndex'),4 isIndex = require('./_isIndex'),
5 isKey = require('./_isKey'),
6 isLength = require('./isLength'),5 isLength = require('./isLength'),
7 toKey = require('./_toKey');6 toKey = require('./_toKey');
8 7

@@ -16,7 +15,7 @@

16 * @returns {boolean} Returns `true` if `path` exists, else `false`.15 * @returns {boolean} Returns `true` if `path` exists, else `false`.
17 */16 */
18function hasPath(object, path, hasFunc) {17function hasPath(object, path, hasFunc) {
19 path = isKey(path, object) ? [path] : castPath(path);18 path = castPath(path, object);
20 19
21 var index = -1,20 var index = -1,
22 length = path.length,21 length = path.length,

_getSymbols.js +++16---2

View file

@@ -1,6 +1,12 @@

1var overArg = require('./_overArg'),1var arrayFilter = require('./_arrayFilter'),
2 stubArray = require('./stubArray');2 stubArray = require('./stubArray');
3 3
4/** Used for built-in method references. */
5var objectProto = Object.prototype;
6
7/** Built-in value references. */
8var propertyIsEnumerable = objectProto.propertyIsEnumerable;
9
4/* Built-in method references for those with the same name as other `lodash` methods. */10/* Built-in method references for those with the same name as other `lodash` methods. */
5var nativeGetSymbols = Object.getOwnPropertySymbols;11var nativeGetSymbols = Object.getOwnPropertySymbols;
6 12

@@ -11,6 +17,14 @@

11 * @param {Object} object The object to query.17 * @param {Object} object The object to query.
12 * @returns {Array} Returns the array of symbols.18 * @returns {Array} Returns the array of symbols.
13 */19 */
14var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;20var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
21 if (object == null) {
22 return [];
23 }
24 object = Object(object);
25 return arrayFilter(nativeGetSymbols(object), function(symbol) {
26 return propertyIsEnumerable.call(object, symbol);
27 });
28};
15 29
16module.exports = getSymbols;30module.exports = getSymbols;

isEqual.js +++1---1

View file

@@ -8,7 +8,7 @@

8 * date objects, error objects, maps, numbers, `Object` objects, regexes,8 * date objects, error objects, maps, numbers, `Object` objects, regexes,
9 * sets, strings, symbols, and typed arrays. `Object` objects are compared9 * sets, strings, symbols, and typed arrays. `Object` objects are compared
10 * by their own, not inherited, enumerable properties. Functions and DOM10 * by their own, not inherited, enumerable properties. Functions and DOM
11 * nodes are **not** supported.11 * nodes are compared by strict equality, i.e. `===`.
12 *12 *
13 * @static13 * @static
14 * @memberOf _14 * @memberOf _

_equalObjects.js +++8---7

View file

@@ -1,4 +1,4 @@

1var keys = require('./keys');1var getAllKeys = require('./_getAllKeys');
2 2
3/** Used to compose bitmasks for value comparisons. */3/** Used to compose bitmasks for value comparisons. */
4var COMPARE_PARTIAL_FLAG = 1;4var COMPARE_PARTIAL_FLAG = 1;

@@ -24,9 +24,9 @@

24 */24 */
25function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {25function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
26 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,26 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
27 objProps = keys(object),27 objProps = getAllKeys(object),
28 objLength = objProps.length,28 objLength = objProps.length,
29 othProps = keys(other),29 othProps = getAllKeys(other),
30 othLength = othProps.length;30 othLength = othProps.length;
31 31
32 if (objLength != othLength && !isPartial) {32 if (objLength != othLength && !isPartial) {

@@ -39,10 +39,11 @@

39 return false;39 return false;
40 }40 }
41 }41 }
42 // Assume cyclic values are equal.
43 var stacked = stack.get(object);
44 if (stacked && stack.get(other)) {
45 return stacked == other;42 // Check that cyclic values are equal.
43 var objStacked = stack.get(object);
44 var othStacked = stack.get(other);
45 if (objStacked && othStacked) {
46 return objStacked == other && othStacked == object;
46 }47 }
47 var result = true;48 var result = true;
48 stack.set(object, other);49 stack.set(object, other);

_equalArrays.js +++5---4

View file

@@ -27,10 +27,11 @@

27 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {27 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
28 return false;28 return false;
29 }29 }
30 // Assume cyclic values are equal.
31 var stacked = stack.get(array);
32 if (stacked && stack.get(other)) {
33 return stacked == other;30 // Check that cyclic values are equal.
31 var arrStacked = stack.get(array);
32 var othStacked = stack.get(other);
33 if (arrStacked && othStacked) {
34 return arrStacked == other && othStacked == array;
34 }35 }
35 var index = -1,36 var index = -1,
36 result = true,37 result = true,

_createWrap.js +++1---1

View file

@@ -83,7 +83,7 @@

83 thisArg = newData[2];83 thisArg = newData[2];
84 partials = newData[3];84 partials = newData[3];
85 holders = newData[4];85 holders = newData[4];
86 arity = newData[9] = newData[9] == null86 arity = newData[9] = newData[9] === undefined
87 ? (isBindKey ? 0 : func.length)87 ? (isBindKey ? 0 : func.length)
88 : nativeMax(newData[9] - length, 0);88 : nativeMax(newData[9] - length, 0);
89 89

_createRound.js +++6---4

View file

@@ -1,9 +1,11 @@

1var toInteger = require('./toInteger'),1var root = require('./_root'),
2 toInteger = require('./toInteger'),
2 toNumber = require('./toNumber'),3 toNumber = require('./toNumber'),
3 toString = require('./toString');4 toString = require('./toString');
4 5
5/* Built-in method references for those with the same name as other `lodash` methods. */6/* Built-in method references for those with the same name as other `lodash` methods. */
6var nativeMin = Math.min;7var nativeIsFinite = root.isFinite,
8 nativeMin = Math.min;
7 9
8/**10/**
9 * Creates a function like `_.round`.11 * Creates a function like `_.round`.

@@ -16,8 +18,8 @@

16 var func = Math[methodName];18 var func = Math[methodName];
17 return function(number, precision) {19 return function(number, precision) {
18 number = toNumber(number);20 number = toNumber(number);
19 precision = nativeMin(toInteger(precision), 292);
20 if (precision) {21 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
22 if (precision && nativeIsFinite(number)) {
21 // Shift with exponential notation to avoid floating-point issues.23 // Shift with exponential notation to avoid floating-point issues.
22 // See [MDN](https://mdn.io/round#Examples) for more details.24 // See [MDN](https://mdn.io/round#Examples) for more details.
23 var pair = (toString(number) + 'e').split('e'),25 var pair = (toString(number) + 'e').split('e'),

_createFlow.js +++1---5

View file

@@ -5,9 +5,6 @@

5 isArray = require('./isArray'),5 isArray = require('./isArray'),
6 isLaziable = require('./_isLaziable');6 isLaziable = require('./_isLaziable');
7 7
8/** Used as the size to enable large array optimizations. */
9var LARGE_ARRAY_SIZE = 200;
10
11/** Error message constants. */8/** Error message constants. */
12var FUNC_ERROR_TEXT = 'Expected a function';9var FUNC_ERROR_TEXT = 'Expected a function';
13 10

@@ -64,8 +61,7 @@

64 var args = arguments,61 var args = arguments,
65 value = args[0];62 value = args[0];
66 63
67 if (wrapper && args.length == 1 &&
68 isArray(value) && value.length >= LARGE_ARRAY_SIZE) {64 if (wrapper && args.length == 1 && isArray(value)) {
69 return wrapper.plant(value).value();65 return wrapper.plant(value).value();
70 }66 }
71 var index = 0,67 var index = 0,

lodash.js +++386---244

View file
Large diffs are not rendered by default.

matches.js +++7---0

View file

@@ -16,6 +16,9 @@

16 * values against any array or object value, respectively. See `_.isEqual`16 * values against any array or object value, respectively. See `_.isEqual`
17 * for a list of supported value comparisons.17 * for a list of supported value comparisons.
18 *18 *
19 * **Note:** Multiple values can be checked by combining several matchers
20 * using `_.overSome`
21 *
19 * @static22 * @static
20 * @memberOf _23 * @memberOf _
21 * @since 3.0.024 * @since 3.0.0

@@ -31,6 +34,10 @@

31 *34 *
32 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));35 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
33 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]36 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
37 *
38 * // Checking for several possible values
39 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
40 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
34 */41 */
35function matches(source) {42function matches(source) {
36 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));43 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));

matchesProperty.js +++7---0

View file

@@ -13,6 +13,9 @@

13 * `srcValue` values against any array or object value, respectively. See13 * `srcValue` values against any array or object value, respectively. See
14 * `_.isEqual` for a list of supported value comparisons.14 * `_.isEqual` for a list of supported value comparisons.
15 *15 *
16 * **Note:** Multiple values can be checked by combining several matchers
17 * using `_.overSome`
18 *
16 * @static19 * @static
17 * @memberOf _20 * @memberOf _
18 * @since 3.2.021 * @since 3.2.0

@@ -29,6 +32,10 @@

29 *32 *
30 * _.find(objects, _.matchesProperty('a', 4));33 * _.find(objects, _.matchesProperty('a', 4));
31 * // => { 'a': 4, 'b': 5, 'c': 6 }34 * // => { 'a': 4, 'b': 5, 'c': 6 }
35 *
36 * // Checking for several possible values
37 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
38 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
32 */39 */
33function matchesProperty(path, srcValue) {40function matchesProperty(path, srcValue) {
34 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));41 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));

_cloneSet.js +++0---22

View file
This file was deleted.

_cloneMap.js +++0---22

View file
This file was deleted.

_castPath.js +++9---3

View file

@@ -1,15 +1,21 @@

1var isArray = require('./isArray'),1var isArray = require('./isArray'),
2 stringToPath = require('./_stringToPath');2 isKey = require('./_isKey'),
3 stringToPath = require('./_stringToPath'),
4 toString = require('./toString');
3 5
4/**6/**
5 * Casts `value` to a path array if it's not one.7 * Casts `value` to a path array if it's not one.
6 *8 *
7 * @private9 * @private
8 * @param {*} value The value to inspect.10 * @param {*} value The value to inspect.
11 * @param {Object} [object] The object to query keys on.
9 * @returns {Array} Returns the cast property path array.12 * @returns {Array} Returns the cast property path array.
10 */13 */
11function castPath(value) {
12 return isArray(value) ? value : stringToPath(value);14function castPath(value, object) {
15 if (isArray(value)) {
16 return value;
17 }
18 return isKey(value, object) ? [value] : stringToPath(toString(value));
13}19}
14 20
15module.exports = castPath;21module.exports = castPath;

omit.js +++13---3

View file

@@ -1,6 +1,9 @@

1var baseClone = require('./_baseClone'),1var arrayMap = require('./_arrayMap'),
2 baseClone = require('./_baseClone'),
2 baseUnset = require('./_baseUnset'),3 baseUnset = require('./_baseUnset'),
4 castPath = require('./_castPath'),
3 copyObject = require('./_copyObject'),5 copyObject = require('./_copyObject'),
6 customOmitClone = require('./_customOmitClone'),
4 flatRest = require('./_flatRest'),7 flatRest = require('./_flatRest'),
5 getAllKeysIn = require('./_getAllKeysIn');8 getAllKeysIn = require('./_getAllKeysIn');
6 9

@@ -34,9 +37,16 @@

34 if (object == null) {37 if (object == null) {
35 return result;38 return result;
36 }39 }
40 var isDeep = false;
41 paths = arrayMap(paths, function(path) {
42 path = castPath(path, object);
43 isDeep || (isDeep = path.length > 1);
44 return path;
45 });
37 copyObject(object, getAllKeysIn(object), result);46 copyObject(object, getAllKeysIn(object), result);
38 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG);
39 47 if (isDeep) {
48 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
49 }
40 var length = paths.length;50 var length = paths.length;
41 while (length--) {51 while (length--) {
42 baseUnset(result, paths[length]);52 baseUnset(result, paths[length]);

_baseUnset.js +++2---11

View file

@@ -1,15 +1,8 @@

1var castPath = require('./_castPath'),1var castPath = require('./_castPath'),
2 isKey = require('./_isKey'),
3 last = require('./last'),2 last = require('./last'),
4 parent = require('./_parent'),3 parent = require('./_parent'),
5 toKey = require('./_toKey');4 toKey = require('./_toKey');
6 5
7/** Used for built-in method references. */
8var objectProto = Object.prototype;
9
10/** Used to check objects for own properties. */
11var hasOwnProperty = objectProto.hasOwnProperty;
12
13/**6/**
14 * The base implementation of `_.unset`.7 * The base implementation of `_.unset`.
15 *8 *

@@ -19,11 +12,9 @@

19 * @returns {boolean} Returns `true` if the property is deleted, else `false`.12 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
20 */13 */
21function baseUnset(object, path) {14function baseUnset(object, path) {
22 path = isKey(path, object) ? [path] : castPath(path);15 path = castPath(path, object);
23 object = parent(object, path);16 object = parent(object, path);
24
25 var key = toKey(last(path));
26 return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];17 return object == null || delete object[toKey(last(path))];
27}18}
28 19
29module.exports = baseUnset;20module.exports = baseUnset;

overEvery.js +++4---0

View file

@@ -5,6 +5,10 @@

5 * Creates a function that checks if **all** of the `predicates` return5 * Creates a function that checks if **all** of the `predicates` return
6 * truthy when invoked with the arguments it receives.6 * truthy when invoked with the arguments it receives.
7 *7 *
8 * Following shorthands are possible for providing predicates.
9 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
10 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
11 *
8 * @static12 * @static
9 * @memberOf _13 * @memberOf _
10 * @since 4.0.014 * @since 4.0.0

overSome.js +++7---0

View file

@@ -5,6 +5,10 @@

5 * Creates a function that checks if **any** of the `predicates` return5 * Creates a function that checks if **any** of the `predicates` return
6 * truthy when invoked with the arguments it receives.6 * truthy when invoked with the arguments it receives.
7 *7 *
8 * Following shorthands are possible for providing predicates.
9 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
10 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
11 *
8 * @static12 * @static
9 * @memberOf _13 * @memberOf _
10 * @since 4.0.014 * @since 4.0.0

@@ -24,6 +28,9 @@

24 *28 *
25 * func(NaN);29 * func(NaN);
26 * // => false30 * // => false
31 *
32 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
33 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
27 */34 */
28var overSome = createOver(arraySome);35var overSome = createOver(arraySome);
29 36

parseInt.js +++1---1

View file

@@ -1,7 +1,7 @@

1var root = require('./_root'),1var root = require('./_root'),
2 toString = require('./toString');2 toString = require('./toString');
3 3
4/** Used to match leading and trailing whitespace. */4/** Used to match leading whitespace. */
5var reTrimStart = /^\s+/;5var reTrimStart = /^\s+/;
6 6
7/* Built-in method references for those with the same name as other `lodash` methods. */7/* Built-in method references for those with the same name as other `lodash` methods. */

_baseSortedIndexBy.js +++7---4

View file

@@ -22,11 +22,14 @@

22 * into `array`.22 * into `array`.
23 */23 */
24function baseSortedIndexBy(array, value, iteratee, retHighest) {24function baseSortedIndexBy(array, value, iteratee, retHighest) {
25 var low = 0,
26 high = array == null ? 0 : array.length;
27 if (high === 0) {
28 return 0;
29 }
30
25 value = iteratee(value);31 value = iteratee(value);
26
27 var low = 0,
28 high = array == null ? 0 : array.length,
29 valIsNaN = value !== value,32 var valIsNaN = value !== value,
30 valIsNull = value === null,33 valIsNull = value === null,
31 valIsSymbol = isSymbol(value),34 valIsSymbol = isSymbol(value),
32 valIsUndefined = value === undefined;35 valIsUndefined = value === undefined;

pick.js +++3---5

View file

@@ -1,7 +1,5 @@

1var arrayMap = require('./_arrayMap'),
2 basePick = require('./_basePick'),
3 flatRest = require('./_flatRest'),
4 toKey = require('./_toKey');1var basePick = require('./_basePick'),
2 flatRest = require('./_flatRest');
5 3
6/**4/**
7 * Creates an object composed of the picked `object` properties.5 * Creates an object composed of the picked `object` properties.

@@ -21,7 +19,7 @@

21 * // => { 'a': 1, 'c': 3 }19 * // => { 'a': 1, 'c': 3 }
22 */20 */
23var pick = flatRest(function(object, paths) {21var pick = flatRest(function(object, paths) {
24 return object == null ? {} : basePick(object, arrayMap(paths, toKey));22 return object == null ? {} : basePick(object, paths);
25});23});
26 24
27module.exports = pick;25module.exports = pick;

pickBy.js +++12---2

View file

@@ -1,4 +1,5 @@

1var baseIteratee = require('./_baseIteratee'),1var arrayMap = require('./_arrayMap'),
2 baseIteratee = require('./_baseIteratee'),
2 basePickBy = require('./_basePickBy'),3 basePickBy = require('./_basePickBy'),
3 getAllKeysIn = require('./_getAllKeysIn');4 getAllKeysIn = require('./_getAllKeysIn');
4 5

@@ -21,7 +22,16 @@

21 * // => { 'a': 1, 'c': 3 }22 * // => { 'a': 1, 'c': 3 }
22 */23 */
23function pickBy(object, predicate) {24function pickBy(object, predicate) {
24 return object == null ? {} : basePickBy(object, getAllKeysIn(object), baseIteratee(predicate));25 if (object == null) {
26 return {};
27 }
28 var props = arrayMap(getAllKeysIn(object), function(prop) {
29 return [prop];
30 });
31 predicate = baseIteratee(predicate);
32 return basePickBy(object, props, function(value, path) {
33 return predicate(value, path[0]);
34 });
25}35}
26 36
27module.exports = pickBy;37module.exports = pickBy;

_baseSet.js +++5---2

View file

@@ -1,7 +1,6 @@

1var assignValue = require('./_assignValue'),1var assignValue = require('./_assignValue'),
2 castPath = require('./_castPath'),2 castPath = require('./_castPath'),
3 isIndex = require('./_isIndex'),3 isIndex = require('./_isIndex'),
4 isKey = require('./_isKey'),
5 isObject = require('./isObject'),4 isObject = require('./isObject'),
6 toKey = require('./_toKey');5 toKey = require('./_toKey');
7 6

@@ -19,7 +18,7 @@

19 if (!isObject(object)) {18 if (!isObject(object)) {
20 return object;19 return object;
21 }20 }
22 path = isKey(path, object) ? [path] : castPath(path);21 path = castPath(path, object);
23 22
24 var index = -1,23 var index = -1,
25 length = path.length,24 length = path.length,

@@ -30,6 +29,10 @@

30 var key = toKey(path[index]),29 var key = toKey(path[index]),
31 newValue = value;30 newValue = value;
32 31
32 if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
33 return object;
34 }
35
33 if (index != lastIndex) {36 if (index != lastIndex) {
34 var objValue = nested[key];37 var objValue = nested[key];
35 newValue = customizer ? customizer(objValue, key, nested) : undefined;38 newValue = customizer ? customizer(objValue, key, nested) : undefined;

_basePullAt.js +++4---17

View file

@@ -1,9 +1,5 @@

1var castPath = require('./_castPath'),
2 isIndex = require('./_isIndex'),
3 isKey = require('./_isKey'),
4 last = require('./last'),
5 parent = require('./_parent'),
6 toKey = require('./_toKey');1var baseUnset = require('./_baseUnset'),
2 isIndex = require('./_isIndex');
7 3
8/** Used for built-in method references. */4/** Used for built-in method references. */
9var arrayProto = Array.prototype;5var arrayProto = Array.prototype;

@@ -30,18 +26,9 @@

30 var previous = index;26 var previous = index;
31 if (isIndex(index)) {27 if (isIndex(index)) {
32 splice.call(array, index, 1);28 splice.call(array, index, 1);
29 } else {
30 baseUnset(array, index);
33 }31 }
34 else if (!isKey(index, array)) {
35 var path = castPath(index),
36 object = parent(array, path);
37
38 if (object != null) {
39 delete object[toKey(last(path))];
40 }
41 }
42 else {
43 delete array[toKey(index)];
44 }
45 }32 }
46 }33 }
47 return array;34 return array;

_basePickBy.js +++3---2

View file

@@ -1,5 +1,6 @@

1var baseGet = require('./_baseGet'),1var baseGet = require('./_baseGet'),
2 baseSet = require('./_baseSet');2 baseSet = require('./_baseSet'),
3 castPath = require('./_castPath');
3 4
4/**5/**
5 * The base implementation of `_.pickBy` without support for iteratee shorthands.6 * The base implementation of `_.pickBy` without support for iteratee shorthands.

@@ -20,7 +21,7 @@

20 value = baseGet(object, path);21 value = baseGet(object, path);
21 22
22 if (predicate(value, path)) {23 if (predicate(value, path)) {
23 baseSet(result, path, value);24 baseSet(result, castPath(path, object), value);
24 }25 }
25 }26 }
26 return result;27 return result;

_basePick.js +++0---1

View file

@@ -11,7 +11,6 @@

11 * @returns {Object} Returns the new object.11 * @returns {Object} Returns the new object.
12 */12 */
13function basePick(object, paths) {13function basePick(object, paths) {
14 object = Object(object);
15 return basePickBy(object, paths, function(value, path) {14 return basePickBy(object, paths, function(value, path) {
16 return hasIn(object, path);15 return hasIn(object, path);
17 });16 });

_baseOrderBy.js +++17---2

View file

@@ -1,10 +1,12 @@

1var arrayMap = require('./_arrayMap'),1var arrayMap = require('./_arrayMap'),
2 baseGet = require('./_baseGet'),
2 baseIteratee = require('./_baseIteratee'),3 baseIteratee = require('./_baseIteratee'),
3 baseMap = require('./_baseMap'),4 baseMap = require('./_baseMap'),
4 baseSortBy = require('./_baseSortBy'),5 baseSortBy = require('./_baseSortBy'),
5 baseUnary = require('./_baseUnary'),6 baseUnary = require('./_baseUnary'),
6 compareMultiple = require('./_compareMultiple'),7 compareMultiple = require('./_compareMultiple'),
7 identity = require('./identity');8 identity = require('./identity'),
9 isArray = require('./isArray');
8 10
9/**11/**
10 * The base implementation of `_.orderBy` without param guards.12 * The base implementation of `_.orderBy` without param guards.

@@ -16,8 +18,21 @@

16 * @returns {Array} Returns the new sorted array.18 * @returns {Array} Returns the new sorted array.
17 */19 */
18function baseOrderBy(collection, iteratees, orders) {20function baseOrderBy(collection, iteratees, orders) {
21 if (iteratees.length) {
22 iteratees = arrayMap(iteratees, function(iteratee) {
23 if (isArray(iteratee)) {
24 return function(value) {
25 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
26 }
27 }
28 return iteratee;
29 });
30 } else {
31 iteratees = [identity];
32 }
33
19 var index = -1;34 var index = -1;
20 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));35 iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
21 36
22 var result = baseMap(collection, function(value, key, collection) {37 var result = baseMap(collection, function(value, key, collection) {
23 var criteria = arrayMap(iteratees, function(iteratee) {38 var criteria = arrayMap(iteratees, function(iteratee) {

result.js +++2---3

View file

@@ -1,6 +1,5 @@

1var castPath = require('./_castPath'),1var castPath = require('./_castPath'),
2 isFunction = require('./isFunction'),2 isFunction = require('./isFunction'),
3 isKey = require('./_isKey'),
4 toKey = require('./_toKey');3 toKey = require('./_toKey');
5 4
6/**5/**

@@ -33,15 +32,15 @@

33 * // => 'default'32 * // => 'default'
34 */33 */
35function result(object, path, defaultValue) {34function result(object, path, defaultValue) {
36 path = isKey(path, object) ? [path] : castPath(path);35 path = castPath(path, object);
37 36
38 var index = -1,37 var index = -1,
39 length = path.length;38 length = path.length;
40 39
41 // Ensure the loop is entered when path is empty.40 // Ensure the loop is entered when path is empty.
42 if (!length) {41 if (!length) {
42 length = 1;
43 object = undefined;43 object = undefined;
44 length = 1;
45 }44 }
46 while (++index < length) {45 while (++index < length) {
47 var value = object == null ? undefined : object[toKey(path[index])];46 var value = object == null ? undefined : object[toKey(path[index])];

_baseMergeDeep.js +++4---3

View file

@@ -11,6 +11,7 @@

11 isObject = require('./isObject'),11 isObject = require('./isObject'),
12 isPlainObject = require('./isPlainObject'),12 isPlainObject = require('./isPlainObject'),
13 isTypedArray = require('./isTypedArray'),13 isTypedArray = require('./isTypedArray'),
14 safeGet = require('./_safeGet'),
14 toPlainObject = require('./toPlainObject');15 toPlainObject = require('./toPlainObject');
15 16
16/**17/**

@@ -29,8 +30,8 @@

29 * counterparts.30 * counterparts.
30 */31 */
31function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {32function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
32 var objValue = object[key],
33 srcValue = source[key],33 var objValue = safeGet(object, key),
34 srcValue = safeGet(source, key),
34 stacked = stack.get(srcValue);35 stacked = stack.get(srcValue);
35 36
36 if (stacked) {37 if (stacked) {

@@ -73,7 +74,7 @@

73 if (isArguments(objValue)) {74 if (isArguments(objValue)) {
74 newValue = toPlainObject(objValue);75 newValue = toPlainObject(objValue);
75 }76 }
76 else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {77 else if (!isObject(objValue) || isFunction(objValue)) {
77 newValue = initCloneObject(srcValue);78 newValue = initCloneObject(srcValue);
78 }79 }
79 }80 }

_baseMerge.js +++4---3

View file

@@ -3,7 +3,8 @@

3 baseFor = require('./_baseFor'),3 baseFor = require('./_baseFor'),
4 baseMergeDeep = require('./_baseMergeDeep'),4 baseMergeDeep = require('./_baseMergeDeep'),
5 isObject = require('./isObject'),5 isObject = require('./isObject'),
6 keysIn = require('./keysIn');6 keysIn = require('./keysIn'),
7 safeGet = require('./_safeGet');
7 8
8/**9/**
9 * The base implementation of `_.merge` without support for multiple sources.10 * The base implementation of `_.merge` without support for multiple sources.

@@ -21,13 +22,13 @@

21 return;22 return;
22 }23 }
23 baseFor(source, function(srcValue, key) {24 baseFor(source, function(srcValue, key) {
25 stack || (stack = new Stack);
24 if (isObject(srcValue)) {26 if (isObject(srcValue)) {
25 stack || (stack = new Stack);
26 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);27 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
27 }28 }
28 else {29 else {
29 var newValue = customizer30 var newValue = customizer
30 ? customizer(object[key], srcValue, (key + ''), object, source, stack)31 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
31 : undefined;32 : undefined;
32 33
33 if (newValue === undefined) {34 if (newValue === undefined) {

sortBy.js +++3---3

View file

@@ -22,15 +22,15 @@

22 * var users = [22 * var users = [
23 * { 'user': 'fred', 'age': 48 },23 * { 'user': 'fred', 'age': 48 },
24 * { 'user': 'barney', 'age': 36 },24 * { 'user': 'barney', 'age': 36 },
25 * { 'user': 'fred', 'age': 40 },25 * { 'user': 'fred', 'age': 30 },
26 * { 'user': 'barney', 'age': 34 }26 * { 'user': 'barney', 'age': 34 }
27 * ];27 * ];
28 *28 *
29 * _.sortBy(users, [function(o) { return o.user; }]);29 * _.sortBy(users, [function(o) { return o.user; }]);
30 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]30 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
31 *31 *
32 * _.sortBy(users, ['user', 'age']);32 * _.sortBy(users, ['user', 'age']);
33 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]33 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
34 */34 */
35var sortBy = baseRest(function(collection, iteratees) {35var sortBy = baseRest(function(collection, iteratees) {
36 if (collection == null) {36 if (collection == null) {

_baseIsEqualDeep.js +++5---10

View file

@@ -38,17 +38,12 @@

38function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {38function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
39 var objIsArr = isArray(object),39 var objIsArr = isArray(object),
40 othIsArr = isArray(other),40 othIsArr = isArray(other),
41 objTag = arrayTag,
42 othTag = arrayTag;41 objTag = objIsArr ? arrayTag : getTag(object),
42 othTag = othIsArr ? arrayTag : getTag(other);
43 43
44 if (!objIsArr) {
45 objTag = getTag(object);
46 objTag = objTag == argsTag ? objectTag : objTag;
47 }
48 if (!othIsArr) {
49 othTag = getTag(other);
50 othTag = othTag == argsTag ? objectTag : othTag;
51 }44 objTag = objTag == argsTag ? objectTag : objTag;
45 othTag = othTag == argsTag ? objectTag : othTag;
46
52 var objIsObj = objTag == objectTag,47 var objIsObj = objTag == objectTag,
53 othIsObj = othTag == objectTag,48 othIsObj = othTag == objectTag,
54 isSameTag = objTag == othTag;49 isSameTag = objTag == othTag;

_baseIsEqual.js +++1---2

View file

@@ -1,5 +1,4 @@

1var baseIsEqualDeep = require('./_baseIsEqualDeep'),1var baseIsEqualDeep = require('./_baseIsEqualDeep'),
2 isObject = require('./isObject'),
3 isObjectLike = require('./isObjectLike');2 isObjectLike = require('./isObjectLike');
4 3
5/**4/**

@@ -20,7 +19,7 @@

20 if (value === other) {19 if (value === other) {
21 return true;20 return true;
22 }21 }
23 if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {22 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
24 return value !== value && other !== other;23 return value !== value && other !== other;
25 }24 }
26 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);25 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);

spread.js +++1---5

View file

@@ -48,18 +48,14 @@

48 if (typeof func != 'function') {48 if (typeof func != 'function') {
49 throw new TypeError(FUNC_ERROR_TEXT);49 throw new TypeError(FUNC_ERROR_TEXT);
50 }50 }
51 start = start === undefined ? 0 : nativeMax(toInteger(start), 0);51 start = start == null ? 0 : nativeMax(toInteger(start), 0);
52 return baseRest(function(args) {52 return baseRest(function(args) {
53 var array = args[start],53 var array = args[start],
54 lastIndex = args.length - 1,
55 otherArgs = castSlice(args, 0, start);54 otherArgs = castSlice(args, 0, start);
56 55
57 if (array) {56 if (array) {
58 arrayPush(otherArgs, array);57 arrayPush(otherArgs, array);
59 }58 }
60 if (start != lastIndex) {
61 arrayPush(otherArgs, castSlice(args, start + 1));
62 }
63 return apply(func, this, otherArgs);59 return apply(func, this, otherArgs);
64 });60 });
65}61}

_baseInvoke.js +++3---7

View file

@@ -1,6 +1,5 @@

1var apply = require('./_apply'),1var apply = require('./_apply'),
2 castPath = require('./_castPath'),2 castPath = require('./_castPath'),
3 isKey = require('./_isKey'),
4 last = require('./last'),3 last = require('./last'),
5 parent = require('./_parent'),4 parent = require('./_parent'),
6 toKey = require('./_toKey');5 toKey = require('./_toKey');

@@ -16,12 +15,9 @@

16 * @returns {*} Returns the result of the invoked method.15 * @returns {*} Returns the result of the invoked method.
17 */16 */
18function baseInvoke(object, path, args) {17function baseInvoke(object, path, args) {
19 if (!isKey(path, object)) {
20 path = castPath(path);
21 object = parent(object, path);
22 path = last(path);
23 }
24 var func = object == null ? object : object[toKey(path)];18 path = castPath(path, object);
19 object = parent(object, path);
20 var func = object == null ? object : object[toKey(last(path))];
25 return func == null ? undefined : apply(func, object, args);21 return func == null ? undefined : apply(func, object, args);
26}22}
27 23

startsWith.js +++4---1

View file

@@ -28,7 +28,10 @@

28 */28 */
29function startsWith(string, target, position) {29function startsWith(string, target, position) {
30 string = toString(string);30 string = toString(string);
31 position = baseClamp(toInteger(position), 0, string.length);31 position = position == null
32 ? 0
33 : baseClamp(toInteger(position), 0, string.length);
34
32 target = baseToString(target);35 target = baseToString(target);
33 return string.slice(position, position + target.length) == target;36 return string.slice(position, position + target.length) == target;
34}37}

_baseGetTag.js +++1---2

View file

@@ -20,8 +20,7 @@

20 if (value == null) {20 if (value == null) {
21 return value === undefined ? undefinedTag : nullTag;21 return value === undefined ? undefinedTag : nullTag;
22 }22 }
23 value = Object(value);
24 return (symToStringTag && symToStringTag in value)23 return (symToStringTag && symToStringTag in Object(value))
25 ? getRawTag(value)24 ? getRawTag(value)
26 : objectToString(value);25 : objectToString(value);
27}26}

_baseGet.js +++1---2

View file

@@ -1,5 +1,4 @@

1var castPath = require('./_castPath'),1var castPath = require('./_castPath'),
2 isKey = require('./_isKey'),
3 toKey = require('./_toKey');2 toKey = require('./_toKey');
4 3
5/**4/**

@@ -11,7 +10,7 @@

11 * @returns {*} Returns the resolved value.10 * @returns {*} Returns the resolved value.
12 */11 */
13function baseGet(object, path) {12function baseGet(object, path) {
14 path = isKey(path, object) ? [path] : castPath(path);13 path = castPath(path, object);
15 14
16 var index = 0,15 var index = 0,
17 length = path.length;16 length = path.length;

takeWhile.js +++1---1

View file

@@ -17,7 +17,7 @@

17 *17 *
18 * var users = [18 * var users = [
19 * { 'user': 'barney', 'active': false },19 * { 'user': 'barney', 'active': false },
20 * { 'user': 'fred', 'active': false},20 * { 'user': 'fred', 'active': false },
21 * { 'user': 'pebbles', 'active': true }21 * { 'user': 'pebbles', 'active': true }
22 * ];22 * ];
23 *23 *

template.js +++40---6

View file

@@ -1,7 +1,7 @@

1var assignInDefaults = require('./_assignInDefaults'),
2 assignInWith = require('./assignInWith'),1var assignInWith = require('./assignInWith'),
3 attempt = require('./attempt'),2 attempt = require('./attempt'),
4 baseValues = require('./_baseValues'),3 baseValues = require('./_baseValues'),
4 customDefaultsAssignIn = require('./_customDefaultsAssignIn'),
5 escapeStringChar = require('./_escapeStringChar'),5 escapeStringChar = require('./_escapeStringChar'),
6 isError = require('./isError'),6 isError = require('./isError'),
7 isIterateeCall = require('./_isIterateeCall'),7 isIterateeCall = require('./_isIterateeCall'),

@@ -10,12 +10,27 @@

10 templateSettings = require('./templateSettings'),10 templateSettings = require('./templateSettings'),
11 toString = require('./toString');11 toString = require('./toString');
12 12
13/** Error message constants. */
14var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
15
13/** Used to match empty string literals in compiled template source. */16/** Used to match empty string literals in compiled template source. */
14var reEmptyStringLeading = /\b__p \+= '';/g,17var reEmptyStringLeading = /\b__p \+= '';/g,
15 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,18 reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
16 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;19 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
17 20
18/**21/**
22 * Used to validate the `validate` option in `_.template` variable.
23 *
24 * Forbids characters which could potentially change the meaning of the function argument definition:
25 * - "()," (modification of function parameters)
26 * - "=" (default value)
27 * - "[]{}" (destructuring of function parameters)
28 * - "/" (beginning of a comment)
29 * - whitespace
30 */
31var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
32
33/**
19 * Used to match34 * Used to match
20 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).35 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
21 */36 */

@@ -27,6 +42,12 @@

27/** Used to match unescaped characters in compiled string literals. */42/** Used to match unescaped characters in compiled string literals. */
28var reUnescapedString = /['\n\r\u2028\u2029\\]/g;43var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
29 44
45/** Used for built-in method references. */
46var objectProto = Object.prototype;
47
48/** Used to check objects for own properties. */
49var hasOwnProperty = objectProto.hasOwnProperty;
50
30/**51/**
31 * Creates a compiled template function that can interpolate data properties52 * Creates a compiled template function that can interpolate data properties
32 * in "interpolate" delimiters, HTML-escape interpolated data properties in53 * in "interpolate" delimiters, HTML-escape interpolated data properties in

@@ -141,9 +162,9 @@

141 options = undefined;162 options = undefined;
142 }163 }
143 string = toString(string);164 string = toString(string);
144 options = assignInWith({}, options, settings, assignInDefaults);165 options = assignInWith({}, options, settings, customDefaultsAssignIn);
145 166
146 var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),167 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
147 importsKeys = keys(imports),168 importsKeys = keys(imports),
148 importsValues = baseValues(imports, importsKeys);169 importsValues = baseValues(imports, importsKeys);
149 170

@@ -162,7 +183,14 @@

162 , 'g');183 , 'g');
163 184
164 // Use a sourceURL for easier debugging.185 // Use a sourceURL for easier debugging.
165 var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : '';186 // The sourceURL gets injected into the source that's eval-ed, so be careful
187 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
188 // and escape the comment, thus injecting code that gets evaled.
189 var sourceURL = hasOwnProperty.call(options, 'sourceURL')
190 ? ('//# sourceURL=' +
191 (options.sourceURL + '').replace(/\s/g, ' ') +
192 '\n')
193 : '';
166 194
167 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {195 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
168 interpolateValue || (interpolateValue = esTemplateValue);196 interpolateValue || (interpolateValue = esTemplateValue);

@@ -193,10 +221,16 @@

193 221
194 // If `variable` is not specified wrap a with-statement around the generated222 // If `variable` is not specified wrap a with-statement around the generated
195 // code to add the data object to the top of the scope chain.223 // code to add the data object to the top of the scope chain.
196 var variable = options.variable;224 var variable = hasOwnProperty.call(options, 'variable') && options.variable;
197 if (!variable) {225 if (!variable) {
198 source = 'with (obj) {\n' + source + '\n}\n';226 source = 'with (obj) {\n' + source + '\n}\n';
199 }227 }
228 // Throw an error if a forbidden character was found in `variable`, to prevent
229 // potential command injection attacks.
230 else if (reForbiddenIdentifierChars.test(variable)) {
231 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
232 }
233
200 // Cleanup code by stripping empty strings.234 // Cleanup code by stripping empty strings.
201 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)235 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
202 .replace(reEmptyStringMiddle, '$1')236 .replace(reEmptyStringMiddle, '$1')

templateSettings.js +++2---2

View file

@@ -5,8 +5,8 @@

5 5
6/**6/**
7 * By default, the template delimiters used by lodash are like those in7 * By default, the template delimiters used by lodash are like those in
8 * embedded Ruby (ERB). Change the following template settings to use
9 * alternative delimiters.8 * embedded Ruby (ERB) as well as ES2015 template strings. Change the
9 * following template settings to use alternative delimiters.
10 *10 *
11 * @static11 * @static
12 * @memberOf _12 * @memberOf _

toNumber.js +++3---5

View file

@@ -1,12 +1,10 @@

1var isObject = require('./isObject'),1var baseTrim = require('./_baseTrim'),
2 isObject = require('./isObject'),
2 isSymbol = require('./isSymbol');3 isSymbol = require('./isSymbol');
3 4
4/** Used as references for various `Number` constants. */5/** Used as references for various `Number` constants. */
5var NAN = 0 / 0;6var NAN = 0 / 0;
6 7
7/** Used to match leading and trailing whitespace. */
8var reTrim = /^\s+|\s+$/g;
9
10/** Used to detect bad signed hexadecimal string values. */8/** Used to detect bad signed hexadecimal string values. */
11var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;9var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
12 10

@@ -56,7 +54,7 @@

56 if (typeof value != 'string') {54 if (typeof value != 'string') {
57 return value === 0 ? value : +value;55 return value === 0 ? value : +value;
58 }56 }
59 value = value.replace(reTrim, '');57 value = baseTrim(value);
60 var isBinary = reIsBinary.test(value);58 var isBinary = reIsBinary.test(value);
61 return (isBinary || reIsOctal.test(value))59 return (isBinary || reIsOctal.test(value))
62 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)60 ? freeParseInt(value.slice(2), isBinary ? 2 : 8)

_baseClone.js +++15---2

View file

@@ -15,8 +15,11 @@

15 initCloneObject = require('./_initCloneObject'),15 initCloneObject = require('./_initCloneObject'),
16 isArray = require('./isArray'),16 isArray = require('./isArray'),
17 isBuffer = require('./isBuffer'),17 isBuffer = require('./isBuffer'),
18 isMap = require('./isMap'),
18 isObject = require('./isObject'),19 isObject = require('./isObject'),
19 keys = require('./keys');20 isSet = require('./isSet'),
21 keys = require('./keys'),
22 keysIn = require('./keysIn');
20 23
21/** Used to compose bitmasks for cloning. */24/** Used to compose bitmasks for cloning. */
22var CLONE_DEEP_FLAG = 1,25var CLONE_DEEP_FLAG = 1,

@@ -123,7 +126,7 @@

123 if (!cloneableTags[tag]) {126 if (!cloneableTags[tag]) {
124 return object ? value : {};127 return object ? value : {};
125 }128 }
126 result = initCloneByTag(value, tag, baseClone, isDeep);129 result = initCloneByTag(value, tag, isDeep);
127 }130 }
128 }131 }
129 // Check for circular references and return its corresponding clone.132 // Check for circular references and return its corresponding clone.

@@ -134,6 +137,16 @@

134 }137 }
135 stack.set(value, result);138 stack.set(value, result);
136 139
140 if (isSet(value)) {
141 value.forEach(function(subValue) {
142 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
143 });
144 } else if (isMap(value)) {
145 value.forEach(function(subValue, key) {
146 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
147 });
148 }
149
137 var keysFunc = isFull150 var keysFunc = isFull
138 ? (isFlat ? getAllKeysIn : getAllKeys)151 ? (isFlat ? getAllKeysIn : getAllKeys)
139 : (isFlat ? keysIn : keys);152 : (isFlat ? keysIn : keys);

toPath.js +++3---2

View file

toSafeInteger.js +++3---1

View file

trim.js +++2---4

View file

trimEnd.js +++3---5

View file

trimStart.js +++1---1

View file

_assignInDefaults.js +++0---27

View file
This file was deleted.

_addSetEntry.js +++0---15

View file
This file was deleted.

_addMapEntry.js +++0---15

View file
This file was deleted.

wrapperLodash.js +++3---3

View file

fp/_util.js +++2---1

View file

fp/_mapping.js +++2---11

View file

fp/_baseConvert.js +++54---21

View file
Large diffs are not rendered by default.

_baseTrim.js +++19---0

View file

_customDefaultsAssignIn.js +++29---0

View file

_customDefaultsMerge.js +++28---0

View file

_customOmitClone.js +++16---0

View file

_safeGet.js +++21---0

View file

_trimmedEndIndex.js +++19---0

View file

flake.lock +++40---0

View file

release.md +++48---0

View file

flake.nix +++20---0

View file