lodash-rails 3.3.1.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lodash/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lodash.compat.js +434 -304
- data/vendor/assets/javascripts/lodash.compat.min.js +89 -87
- data/vendor/assets/javascripts/lodash.js +434 -304
- data/vendor/assets/javascripts/lodash.min.js +85 -85
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21b069cdb16cd8e8562f886f91e344dfef771236
|
4
|
+
data.tar.gz: b713547f4af4d8a245ae0a470e72a50d7d7dce61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f068d7d6704cc08d9b38d7af73a91dbf83c31765cf18a4f972da513ab613327912ba78c6fb9dbec43874d37469e3276ed977a74f13a57d87c11887c53a2e5d
|
7
|
+
data.tar.gz: 3229009d0eacc36987a4df3bb1c7790d9d76b3c12e41ca2ec78c191cec68d8c1fca274b7bf173f4623cd4d034a89695bc85a2096c14c30e8ac5e280e87ddaa04
|
data/README.md
CHANGED
data/lib/lodash/rails/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* lodash 3.
|
3
|
+
* lodash 3.4.0 (Custom Build) <https://lodash.com/>
|
4
4
|
* Build: `lodash compat -o ./lodash.js`
|
5
5
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
6
6
|
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
var undefined;
|
14
14
|
|
15
15
|
/** Used as the semantic version number. */
|
16
|
-
var VERSION = '3.
|
16
|
+
var VERSION = '3.4.0';
|
17
17
|
|
18
18
|
/** Used to compose bitmasks for wrapper metadata. */
|
19
19
|
var BIND_FLAG = 1,
|
@@ -35,9 +35,9 @@
|
|
35
35
|
HOT_SPAN = 16;
|
36
36
|
|
37
37
|
/** Used to indicate the type of lazy iteratees. */
|
38
|
-
var
|
39
|
-
LAZY_MAP_FLAG =
|
40
|
-
|
38
|
+
var LAZY_DROP_WHILE_FLAG = 0,
|
39
|
+
LAZY_MAP_FLAG = 2,
|
40
|
+
LAZY_TAKE_WHILE_FLAG = 3;
|
41
41
|
|
42
42
|
/** Used as the `TypeError` message for "Functions" methods. */
|
43
43
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
@@ -131,7 +131,7 @@
|
|
131
131
|
var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]',
|
132
132
|
lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+';
|
133
133
|
|
134
|
-
return RegExp(upper + '
|
134
|
+
return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
|
135
135
|
}());
|
136
136
|
|
137
137
|
/** Used to detect and test for whitespace. */
|
@@ -259,29 +259,29 @@
|
|
259
259
|
'\u2029': 'u2029'
|
260
260
|
};
|
261
261
|
|
262
|
-
/**
|
263
|
-
* Used as a reference to the global object.
|
264
|
-
*
|
265
|
-
* The `this` value is used if it is the global object to avoid Greasemonkey's
|
266
|
-
* restricted `window` object, otherwise the `window` object is used.
|
267
|
-
*/
|
268
|
-
var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this;
|
269
|
-
|
270
262
|
/** Detect free variable `exports`. */
|
271
263
|
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
272
264
|
|
273
265
|
/** Detect free variable `module`. */
|
274
266
|
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
275
267
|
|
276
|
-
/** Detect free variable `global` from Node.js
|
268
|
+
/** Detect free variable `global` from Node.js. */
|
277
269
|
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
|
278
|
-
|
279
|
-
|
280
|
-
|
270
|
+
|
271
|
+
/** Detect free variable `window`. */
|
272
|
+
var freeWindow = objectTypes[typeof window] && window;
|
281
273
|
|
282
274
|
/** Detect the popular CommonJS extension `module.exports`. */
|
283
275
|
var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
|
284
276
|
|
277
|
+
/**
|
278
|
+
* Used as a reference to the global object.
|
279
|
+
*
|
280
|
+
* The `this` value is used if it is the global object to avoid Greasemonkey's
|
281
|
+
* restricted `window` object, otherwise the `window` object is used.
|
282
|
+
*/
|
283
|
+
var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this;
|
284
|
+
|
285
285
|
/*--------------------------------------------------------------------------*/
|
286
286
|
|
287
287
|
/**
|
@@ -314,14 +314,14 @@
|
|
314
314
|
* @private
|
315
315
|
* @param {Array} array The array to search.
|
316
316
|
* @param {*} value The value to search for.
|
317
|
-
* @param {number}
|
317
|
+
* @param {number} fromIndex The index to search from.
|
318
318
|
* @returns {number} Returns the index of the matched value, else `-1`.
|
319
319
|
*/
|
320
320
|
function baseIndexOf(array, value, fromIndex) {
|
321
321
|
if (value !== value) {
|
322
322
|
return indexOfNaN(array, fromIndex);
|
323
323
|
}
|
324
|
-
var index =
|
324
|
+
var index = fromIndex - 1,
|
325
325
|
length = array.length;
|
326
326
|
|
327
327
|
while (++index < length) {
|
@@ -346,26 +346,6 @@
|
|
346
346
|
return typeof value == 'function' || false;
|
347
347
|
}
|
348
348
|
|
349
|
-
/**
|
350
|
-
* The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer`
|
351
|
-
* to define the sort order of `array` and replaces criteria objects with their
|
352
|
-
* corresponding values.
|
353
|
-
*
|
354
|
-
* @private
|
355
|
-
* @param {Array} array The array to sort.
|
356
|
-
* @param {Function} comparer The function to define sort order.
|
357
|
-
* @returns {Array} Returns `array`.
|
358
|
-
*/
|
359
|
-
function baseSortBy(array, comparer) {
|
360
|
-
var length = array.length;
|
361
|
-
|
362
|
-
array.sort(comparer);
|
363
|
-
while (length--) {
|
364
|
-
array[length] = array[length].value;
|
365
|
-
}
|
366
|
-
return array;
|
367
|
-
}
|
368
|
-
|
369
349
|
/**
|
370
350
|
* Converts `value` to a string if it is not one. An empty string is returned
|
371
351
|
* for `null` or `undefined` values.
|
@@ -439,24 +419,34 @@
|
|
439
419
|
}
|
440
420
|
|
441
421
|
/**
|
442
|
-
* Used by `_.
|
443
|
-
* in a collection and stable sort them in
|
422
|
+
* Used by `_.sortByOrder` to compare multiple properties of each element
|
423
|
+
* in a collection and stable sort them in the following order:
|
424
|
+
*
|
425
|
+
* If orders is unspecified, sort in ascending order for all properties.
|
426
|
+
* Otherwise, for each property, sort in ascending order if its corresponding value in
|
427
|
+
* orders is true, and descending order if false.
|
444
428
|
*
|
445
429
|
* @private
|
446
430
|
* @param {Object} object The object to compare to `other`.
|
447
431
|
* @param {Object} other The object to compare to `object`.
|
432
|
+
* @param {boolean[]} orders The order to sort by for each property.
|
448
433
|
* @returns {number} Returns the sort order indicator for `object`.
|
449
434
|
*/
|
450
|
-
function
|
435
|
+
function compareMultiple(object, other, orders) {
|
451
436
|
var index = -1,
|
452
437
|
objCriteria = object.criteria,
|
453
438
|
othCriteria = other.criteria,
|
454
|
-
length = objCriteria.length
|
439
|
+
length = objCriteria.length,
|
440
|
+
ordersLength = orders.length;
|
455
441
|
|
456
442
|
while (++index < length) {
|
457
443
|
var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
|
458
444
|
if (result) {
|
459
|
-
|
445
|
+
if (index >= ordersLength) {
|
446
|
+
return result;
|
447
|
+
} else {
|
448
|
+
return orders[index] ? result : result * -1;
|
449
|
+
}
|
460
450
|
}
|
461
451
|
}
|
462
452
|
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
@@ -509,13 +499,13 @@
|
|
509
499
|
*
|
510
500
|
* @private
|
511
501
|
* @param {Array} array The array to search.
|
512
|
-
* @param {number}
|
502
|
+
* @param {number} fromIndex The index to search from.
|
513
503
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
514
504
|
* @returns {number} Returns the index of the matched `NaN`, else `-1`.
|
515
505
|
*/
|
516
506
|
function indexOfNaN(array, fromIndex, fromRight) {
|
517
507
|
var length = array.length,
|
518
|
-
index =
|
508
|
+
index = fromIndex + (fromRight ? 0 : -1);
|
519
509
|
|
520
510
|
while ((fromRight ? index-- : ++index < length)) {
|
521
511
|
var other = array[index];
|
@@ -886,26 +876,26 @@
|
|
886
876
|
* `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
|
887
877
|
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
|
888
878
|
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
|
889
|
-
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `
|
890
|
-
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`,
|
891
|
-
* `thru`, `times`, `toArray`, `toPlainObject`, `transform`,
|
892
|
-
* `
|
893
|
-
* `zip`, and `zipObject`
|
879
|
+
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`,
|
880
|
+
* `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`,
|
881
|
+
* `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`,
|
882
|
+
* `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`,
|
883
|
+
* `without`, `wrap`, `xor`, `zip`, and `zipObject`
|
894
884
|
*
|
895
885
|
* The wrapper methods that are **not** chainable by default are:
|
896
|
-
* `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
|
886
|
+
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
|
897
887
|
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
|
898
888
|
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
899
|
-
* `identity`, `includes`, `indexOf`, `
|
900
|
-
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
|
901
|
-
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
889
|
+
* `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`,
|
890
|
+
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
|
891
|
+
* `isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
902
892
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
903
893
|
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
904
894
|
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
905
895
|
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
906
896
|
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
907
|
-
* `startCase`, `startsWith`, `template`, `trim`, `trimLeft`,
|
908
|
-
* `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
897
|
+
* `startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`,
|
898
|
+
* `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
909
899
|
*
|
910
900
|
* The wrapper method `sample` will return a wrapped value when `n` is provided,
|
911
901
|
* otherwise an unwrapped value is returned.
|
@@ -1293,16 +1283,22 @@
|
|
1293
1283
|
while (++iterIndex < iterLength) {
|
1294
1284
|
var data = iteratees[iterIndex],
|
1295
1285
|
iteratee = data.iteratee,
|
1296
|
-
computed = iteratee(value, index, array),
|
1297
1286
|
type = data.type;
|
1298
1287
|
|
1288
|
+
if (type != LAZY_DROP_WHILE_FLAG) {
|
1289
|
+
var computed = iteratee(value);
|
1290
|
+
} else {
|
1291
|
+
data.done = data.done && (isRight ? index < data.index : index > data.index);
|
1292
|
+
data.index = index;
|
1293
|
+
computed = data.done || (data.done = !iteratee(value));
|
1294
|
+
}
|
1299
1295
|
if (type == LAZY_MAP_FLAG) {
|
1300
1296
|
value = computed;
|
1301
1297
|
} else if (!computed) {
|
1302
|
-
if (type ==
|
1303
|
-
continue outer;
|
1304
|
-
} else {
|
1298
|
+
if (type == LAZY_TAKE_WHILE_FLAG) {
|
1305
1299
|
break outer;
|
1300
|
+
} else {
|
1301
|
+
continue outer;
|
1306
1302
|
}
|
1307
1303
|
}
|
1308
1304
|
}
|
@@ -1985,7 +1981,7 @@
|
|
1985
1981
|
}
|
1986
1982
|
result.push(value);
|
1987
1983
|
}
|
1988
|
-
else if (indexOf(values, value) < 0) {
|
1984
|
+
else if (indexOf(values, value, 0) < 0) {
|
1989
1985
|
result.push(value);
|
1990
1986
|
}
|
1991
1987
|
}
|
@@ -2138,13 +2134,13 @@
|
|
2138
2134
|
*
|
2139
2135
|
* @private
|
2140
2136
|
* @param {Array} array The array to flatten.
|
2141
|
-
* @param {boolean}
|
2142
|
-
* @param {boolean}
|
2143
|
-
* @param {number}
|
2137
|
+
* @param {boolean} isDeep Specify a deep flatten.
|
2138
|
+
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
|
2139
|
+
* @param {number} fromIndex The index to start from.
|
2144
2140
|
* @returns {Array} Returns the new flattened array.
|
2145
2141
|
*/
|
2146
2142
|
function baseFlatten(array, isDeep, isStrict, fromIndex) {
|
2147
|
-
var index =
|
2143
|
+
var index = fromIndex - 1,
|
2148
2144
|
length = array.length,
|
2149
2145
|
resIndex = -1,
|
2150
2146
|
result = [];
|
@@ -2155,7 +2151,7 @@
|
|
2155
2151
|
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
2156
2152
|
if (isDeep) {
|
2157
2153
|
// Recursively flatten arrays (susceptible to call stack limits).
|
2158
|
-
value = baseFlatten(value, isDeep, isStrict);
|
2154
|
+
value = baseFlatten(value, isDeep, isStrict, 0);
|
2159
2155
|
}
|
2160
2156
|
var valIndex = -1,
|
2161
2157
|
valLength = value.length;
|
@@ -2769,6 +2765,55 @@
|
|
2769
2765
|
return !!result;
|
2770
2766
|
}
|
2771
2767
|
|
2768
|
+
/**
|
2769
|
+
* The base implementation of `_.sortBy` which uses `comparer` to define
|
2770
|
+
* the sort order of `array` and replaces criteria objects with their
|
2771
|
+
* corresponding values.
|
2772
|
+
*
|
2773
|
+
* @private
|
2774
|
+
* @param {Array} array The array to sort.
|
2775
|
+
* @param {Function} comparer The function to define sort order.
|
2776
|
+
* @returns {Array} Returns `array`.
|
2777
|
+
*/
|
2778
|
+
function baseSortBy(array, comparer) {
|
2779
|
+
var length = array.length;
|
2780
|
+
|
2781
|
+
array.sort(comparer);
|
2782
|
+
while (length--) {
|
2783
|
+
array[length] = array[length].value;
|
2784
|
+
}
|
2785
|
+
return array;
|
2786
|
+
}
|
2787
|
+
|
2788
|
+
/**
|
2789
|
+
* The base implementation of `_.sortByOrder` without param guards.
|
2790
|
+
*
|
2791
|
+
* @private
|
2792
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
2793
|
+
* @param {string[]} props The property names to sort by.
|
2794
|
+
* @param {boolean[]} orders The sort orders of `props`.
|
2795
|
+
* @returns {Array} Returns the new sorted array.
|
2796
|
+
*/
|
2797
|
+
function baseSortByOrder(collection, props, orders) {
|
2798
|
+
var index = -1,
|
2799
|
+
length = collection.length,
|
2800
|
+
result = isLength(length) ? Array(length) : [];
|
2801
|
+
|
2802
|
+
baseEach(collection, function(value) {
|
2803
|
+
var length = props.length,
|
2804
|
+
criteria = Array(length);
|
2805
|
+
|
2806
|
+
while (length--) {
|
2807
|
+
criteria[length] = value == null ? undefined : value[props[length]];
|
2808
|
+
}
|
2809
|
+
result[++index] = { 'criteria': criteria, 'index': index, 'value': value };
|
2810
|
+
});
|
2811
|
+
|
2812
|
+
return baseSortBy(result, function(object, other) {
|
2813
|
+
return compareMultiple(object, other, orders);
|
2814
|
+
});
|
2815
|
+
}
|
2816
|
+
|
2772
2817
|
/**
|
2773
2818
|
* The base implementation of `_.uniq` without support for callback shorthands
|
2774
2819
|
* and `this` binding.
|
@@ -2811,7 +2856,7 @@
|
|
2811
2856
|
}
|
2812
2857
|
result.push(value);
|
2813
2858
|
}
|
2814
|
-
else if (indexOf(seen, computed) < 0) {
|
2859
|
+
else if (indexOf(seen, computed, 0) < 0) {
|
2815
2860
|
if (iteratee || isLarge) {
|
2816
2861
|
seen.push(computed);
|
2817
2862
|
}
|
@@ -3115,24 +3160,31 @@
|
|
3115
3160
|
*/
|
3116
3161
|
function createAssigner(assigner) {
|
3117
3162
|
return function() {
|
3118
|
-
var
|
3119
|
-
|
3163
|
+
var args = arguments,
|
3164
|
+
length = args.length,
|
3165
|
+
object = args[0];
|
3120
3166
|
|
3121
3167
|
if (length < 2 || object == null) {
|
3122
3168
|
return object;
|
3123
3169
|
}
|
3124
|
-
|
3125
|
-
|
3170
|
+
var customizer = args[length - 2],
|
3171
|
+
thisArg = args[length - 1],
|
3172
|
+
guard = args[3];
|
3173
|
+
|
3174
|
+
if (length > 3 && typeof customizer == 'function') {
|
3175
|
+
customizer = bindCallback(customizer, thisArg, 5);
|
3176
|
+
length -= 2;
|
3177
|
+
} else {
|
3178
|
+
customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null;
|
3179
|
+
length -= (customizer ? 1 : 0);
|
3126
3180
|
}
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
} else if (length > 2 && typeof arguments[length - 1] == 'function') {
|
3131
|
-
customizer = arguments[--length];
|
3181
|
+
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
3182
|
+
customizer = length == 3 ? null : customizer;
|
3183
|
+
length = 2;
|
3132
3184
|
}
|
3133
3185
|
var index = 0;
|
3134
3186
|
while (++index < length) {
|
3135
|
-
var source =
|
3187
|
+
var source = args[index];
|
3136
3188
|
if (source) {
|
3137
3189
|
assigner(object, source, customizer);
|
3138
3190
|
}
|
@@ -3170,6 +3222,41 @@
|
|
3170
3222
|
return new SetCache(values);
|
3171
3223
|
};
|
3172
3224
|
|
3225
|
+
/**
|
3226
|
+
* Creates a function to compose other functions into a single function.
|
3227
|
+
*
|
3228
|
+
* @private
|
3229
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
3230
|
+
* @returns {Function} Returns the new composer function.
|
3231
|
+
*/
|
3232
|
+
function createComposer(fromRight) {
|
3233
|
+
return function() {
|
3234
|
+
var length = arguments.length,
|
3235
|
+
index = length,
|
3236
|
+
fromIndex = fromRight ? length - 1 : 0;
|
3237
|
+
|
3238
|
+
if (!length) {
|
3239
|
+
return function() { return arguments[0]; };
|
3240
|
+
}
|
3241
|
+
var funcs = Array(length);
|
3242
|
+
while (index--) {
|
3243
|
+
funcs[index] = arguments[index];
|
3244
|
+
if (typeof funcs[index] != 'function') {
|
3245
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
3246
|
+
}
|
3247
|
+
}
|
3248
|
+
return function() {
|
3249
|
+
var index = fromIndex,
|
3250
|
+
result = funcs[index].apply(this, arguments);
|
3251
|
+
|
3252
|
+
while ((fromRight ? index-- : ++index < length)) {
|
3253
|
+
result = funcs[index].call(this, result);
|
3254
|
+
}
|
3255
|
+
return result;
|
3256
|
+
};
|
3257
|
+
};
|
3258
|
+
}
|
3259
|
+
|
3173
3260
|
/**
|
3174
3261
|
* Creates a function that produces compound words out of the words in a
|
3175
3262
|
* given string.
|
@@ -4265,16 +4352,17 @@
|
|
4265
4352
|
* // => [1, 3]
|
4266
4353
|
*/
|
4267
4354
|
function difference() {
|
4268
|
-
var
|
4269
|
-
|
4355
|
+
var args = arguments,
|
4356
|
+
index = -1,
|
4357
|
+
length = args.length;
|
4270
4358
|
|
4271
4359
|
while (++index < length) {
|
4272
|
-
var value =
|
4360
|
+
var value = args[index];
|
4273
4361
|
if (isArray(value) || isArguments(value)) {
|
4274
4362
|
break;
|
4275
4363
|
}
|
4276
4364
|
}
|
4277
|
-
return baseDifference(value, baseFlatten(
|
4365
|
+
return baseDifference(value, baseFlatten(args, false, true, ++index));
|
4278
4366
|
}
|
4279
4367
|
|
4280
4368
|
/**
|
@@ -4386,7 +4474,7 @@
|
|
4386
4474
|
* ];
|
4387
4475
|
*
|
4388
4476
|
* // using the `_.matches` callback shorthand
|
4389
|
-
* _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user');
|
4477
|
+
* _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
|
4390
4478
|
* // => ['barney', 'fred']
|
4391
4479
|
*
|
4392
4480
|
* // using the `_.matchesProperty` callback shorthand
|
@@ -4597,7 +4685,7 @@
|
|
4597
4685
|
*
|
4598
4686
|
* // using the `_.matchesProperty` callback shorthand
|
4599
4687
|
* _.findLastIndex(users, 'active', false);
|
4600
|
-
* // =>
|
4688
|
+
* // => 2
|
4601
4689
|
*
|
4602
4690
|
* // using the `_.property` callback shorthand
|
4603
4691
|
* _.findLastIndex(users, 'active');
|
@@ -4660,7 +4748,7 @@
|
|
4660
4748
|
if (guard && isIterateeCall(array, isDeep, guard)) {
|
4661
4749
|
isDeep = false;
|
4662
4750
|
}
|
4663
|
-
return length ? baseFlatten(array, isDeep) : [];
|
4751
|
+
return length ? baseFlatten(array, isDeep, false, 0) : [];
|
4664
4752
|
}
|
4665
4753
|
|
4666
4754
|
/**
|
@@ -4678,7 +4766,7 @@
|
|
4678
4766
|
*/
|
4679
4767
|
function flattenDeep(array) {
|
4680
4768
|
var length = array ? array.length : 0;
|
4681
|
-
return length ? baseFlatten(array, true) : [];
|
4769
|
+
return length ? baseFlatten(array, true, false, 0) : [];
|
4682
4770
|
}
|
4683
4771
|
|
4684
4772
|
/**
|
@@ -4719,14 +4807,14 @@
|
|
4719
4807
|
return -1;
|
4720
4808
|
}
|
4721
4809
|
if (typeof fromIndex == 'number') {
|
4722
|
-
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) :
|
4810
|
+
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
|
4723
4811
|
} else if (fromIndex) {
|
4724
4812
|
var index = binaryIndex(array, value),
|
4725
4813
|
other = array[index];
|
4726
4814
|
|
4727
4815
|
return (value === value ? value === other : other !== other) ? index : -1;
|
4728
4816
|
}
|
4729
|
-
return baseIndexOf(array, value, fromIndex);
|
4817
|
+
return baseIndexOf(array, value, fromIndex || 0);
|
4730
4818
|
}
|
4731
4819
|
|
4732
4820
|
/**
|
@@ -4789,11 +4877,11 @@
|
|
4789
4877
|
outer:
|
4790
4878
|
while (++index < length) {
|
4791
4879
|
value = array[index];
|
4792
|
-
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) {
|
4880
|
+
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
|
4793
4881
|
argsIndex = argsLength;
|
4794
4882
|
while (--argsIndex) {
|
4795
4883
|
var cache = caches[argsIndex];
|
4796
|
-
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
|
4884
|
+
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) {
|
4797
4885
|
continue outer;
|
4798
4886
|
}
|
4799
4887
|
}
|
@@ -4898,17 +4986,19 @@
|
|
4898
4986
|
* // => [1, 1]
|
4899
4987
|
*/
|
4900
4988
|
function pull() {
|
4901
|
-
var
|
4989
|
+
var args = arguments,
|
4990
|
+
array = args[0];
|
4991
|
+
|
4902
4992
|
if (!(array && array.length)) {
|
4903
4993
|
return array;
|
4904
4994
|
}
|
4905
4995
|
var index = 0,
|
4906
4996
|
indexOf = getIndexOf(),
|
4907
|
-
length =
|
4997
|
+
length = args.length;
|
4908
4998
|
|
4909
4999
|
while (++index < length) {
|
4910
5000
|
var fromIndex = 0,
|
4911
|
-
value =
|
5001
|
+
value = args[index];
|
4912
5002
|
|
4913
5003
|
while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
|
4914
5004
|
splice.call(array, fromIndex, 1);
|
@@ -5338,7 +5428,7 @@
|
|
5338
5428
|
* // => [1, 2, 4]
|
5339
5429
|
*/
|
5340
5430
|
function union() {
|
5341
|
-
return baseUniq(baseFlatten(arguments, false, true));
|
5431
|
+
return baseUniq(baseFlatten(arguments, false, true, 0));
|
5342
5432
|
}
|
5343
5433
|
|
5344
5434
|
/**
|
@@ -6409,104 +6499,6 @@
|
|
6409
6499
|
return func(collection, iteratee);
|
6410
6500
|
}
|
6411
6501
|
|
6412
|
-
/**
|
6413
|
-
* Gets the maximum value of `collection`. If `collection` is empty or falsey
|
6414
|
-
* `-Infinity` is returned. If an iteratee function is provided it is invoked
|
6415
|
-
* for each value in `collection` to generate the criterion by which the value
|
6416
|
-
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
6417
|
-
* arguments; (value, index, collection).
|
6418
|
-
*
|
6419
|
-
* If a property name is provided for `predicate` the created `_.property`
|
6420
|
-
* style callback returns the property value of the given element.
|
6421
|
-
*
|
6422
|
-
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
6423
|
-
* style callback returns `true` for elements that have a matching property
|
6424
|
-
* value, else `false`.
|
6425
|
-
*
|
6426
|
-
* If an object is provided for `predicate` the created `_.matches` style
|
6427
|
-
* callback returns `true` for elements that have the properties of the given
|
6428
|
-
* object, else `false`.
|
6429
|
-
*
|
6430
|
-
* @static
|
6431
|
-
* @memberOf _
|
6432
|
-
* @category Collection
|
6433
|
-
* @param {Array|Object|string} collection The collection to iterate over.
|
6434
|
-
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
6435
|
-
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
6436
|
-
* @returns {*} Returns the maximum value.
|
6437
|
-
* @example
|
6438
|
-
*
|
6439
|
-
* _.max([4, 2, 8, 6]);
|
6440
|
-
* // => 8
|
6441
|
-
*
|
6442
|
-
* _.max([]);
|
6443
|
-
* // => -Infinity
|
6444
|
-
*
|
6445
|
-
* var users = [
|
6446
|
-
* { 'user': 'barney', 'age': 36 },
|
6447
|
-
* { 'user': 'fred', 'age': 40 }
|
6448
|
-
* ];
|
6449
|
-
*
|
6450
|
-
* _.max(users, function(chr) {
|
6451
|
-
* return chr.age;
|
6452
|
-
* });
|
6453
|
-
* // => { 'user': 'fred', 'age': 40 };
|
6454
|
-
*
|
6455
|
-
* // using the `_.property` callback shorthand
|
6456
|
-
* _.max(users, 'age');
|
6457
|
-
* // => { 'user': 'fred', 'age': 40 };
|
6458
|
-
*/
|
6459
|
-
var max = createExtremum(arrayMax);
|
6460
|
-
|
6461
|
-
/**
|
6462
|
-
* Gets the minimum value of `collection`. If `collection` is empty or falsey
|
6463
|
-
* `Infinity` is returned. If an iteratee function is provided it is invoked
|
6464
|
-
* for each value in `collection` to generate the criterion by which the value
|
6465
|
-
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
6466
|
-
* arguments; (value, index, collection).
|
6467
|
-
*
|
6468
|
-
* If a property name is provided for `predicate` the created `_.property`
|
6469
|
-
* style callback returns the property value of the given element.
|
6470
|
-
*
|
6471
|
-
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
6472
|
-
* style callback returns `true` for elements that have a matching property
|
6473
|
-
* value, else `false`.
|
6474
|
-
*
|
6475
|
-
* If an object is provided for `predicate` the created `_.matches` style
|
6476
|
-
* callback returns `true` for elements that have the properties of the given
|
6477
|
-
* object, else `false`.
|
6478
|
-
*
|
6479
|
-
* @static
|
6480
|
-
* @memberOf _
|
6481
|
-
* @category Collection
|
6482
|
-
* @param {Array|Object|string} collection The collection to iterate over.
|
6483
|
-
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
6484
|
-
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
6485
|
-
* @returns {*} Returns the minimum value.
|
6486
|
-
* @example
|
6487
|
-
*
|
6488
|
-
* _.min([4, 2, 8, 6]);
|
6489
|
-
* // => 2
|
6490
|
-
*
|
6491
|
-
* _.min([]);
|
6492
|
-
* // => Infinity
|
6493
|
-
*
|
6494
|
-
* var users = [
|
6495
|
-
* { 'user': 'barney', 'age': 36 },
|
6496
|
-
* { 'user': 'fred', 'age': 40 }
|
6497
|
-
* ];
|
6498
|
-
*
|
6499
|
-
* _.min(users, function(chr) {
|
6500
|
-
* return chr.age;
|
6501
|
-
* });
|
6502
|
-
* // => { 'user': 'barney', 'age': 36 };
|
6503
|
-
*
|
6504
|
-
* // using the `_.property` callback shorthand
|
6505
|
-
* _.min(users, 'age');
|
6506
|
-
* // => { 'user': 'barney', 'age': 36 };
|
6507
|
-
*/
|
6508
|
-
var min = createExtremum(arrayMin, true);
|
6509
|
-
|
6510
6502
|
/**
|
6511
6503
|
* Creates an array of elements split into two groups, the first of which
|
6512
6504
|
* contains elements `predicate` returns truthy for, while the second of which
|
@@ -6542,7 +6534,7 @@
|
|
6542
6534
|
* _.partition([1.2, 2.3, 3.4], function(n) {
|
6543
6535
|
* return this.floor(n) % 2;
|
6544
6536
|
* }, Math);
|
6545
|
-
* // => [[1, 3], [2]]
|
6537
|
+
* // => [[1.2, 3.4], [2.3]]
|
6546
6538
|
*
|
6547
6539
|
* var users = [
|
6548
6540
|
* { 'user': 'barney', 'age': 36, 'active': false },
|
@@ -6782,8 +6774,8 @@
|
|
6782
6774
|
}
|
6783
6775
|
|
6784
6776
|
/**
|
6785
|
-
* Gets the size of `collection` by returning
|
6786
|
-
*
|
6777
|
+
* Gets the size of `collection` by returning its length for array-like
|
6778
|
+
* values or the number of own enumerable properties for objects.
|
6787
6779
|
*
|
6788
6780
|
* @static
|
6789
6781
|
* @memberOf _
|
@@ -6913,8 +6905,11 @@
|
|
6913
6905
|
* // => ['barney', 'fred', 'pebbles']
|
6914
6906
|
*/
|
6915
6907
|
function sortBy(collection, iteratee, thisArg) {
|
6908
|
+
if (collection == null) {
|
6909
|
+
return [];
|
6910
|
+
}
|
6916
6911
|
var index = -1,
|
6917
|
-
length = collection
|
6912
|
+
length = collection.length,
|
6918
6913
|
result = isLength(length) ? Array(length) : [];
|
6919
6914
|
|
6920
6915
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
@@ -6951,25 +6946,58 @@
|
|
6951
6946
|
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
6952
6947
|
*/
|
6953
6948
|
function sortByAll(collection) {
|
6954
|
-
|
6955
|
-
|
6956
|
-
args = [collection, args[1]];
|
6949
|
+
if (collection == null) {
|
6950
|
+
return [];
|
6957
6951
|
}
|
6958
|
-
var
|
6959
|
-
|
6960
|
-
props = baseFlatten(args, false, false, 1),
|
6961
|
-
result = isLength(length) ? Array(length) : [];
|
6952
|
+
var args = arguments,
|
6953
|
+
guard = args[3];
|
6962
6954
|
|
6963
|
-
|
6964
|
-
|
6965
|
-
|
6955
|
+
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
6956
|
+
args = [collection, args[1]];
|
6957
|
+
}
|
6958
|
+
return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []);
|
6959
|
+
}
|
6966
6960
|
|
6967
|
-
|
6968
|
-
|
6969
|
-
|
6970
|
-
|
6971
|
-
|
6972
|
-
|
6961
|
+
/**
|
6962
|
+
* This method is like `_.sortByAll` except that it allows specifying the
|
6963
|
+
* sort orders of the property names to sort by. A truthy value in `orders`
|
6964
|
+
* will sort the corresponding property name in ascending order while a
|
6965
|
+
* falsey value will sort it in descending order.
|
6966
|
+
*
|
6967
|
+
* @static
|
6968
|
+
* @memberOf _
|
6969
|
+
* @category Collection
|
6970
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
6971
|
+
* @param {string[]} props The property names to sort by.
|
6972
|
+
* @param {boolean[]} orders The sort orders of `props`.
|
6973
|
+
* @returns {Array} Returns the new sorted array.
|
6974
|
+
* @example
|
6975
|
+
*
|
6976
|
+
* var users = [
|
6977
|
+
* { 'user': 'barney', 'age': 36 },
|
6978
|
+
* { 'user': 'fred', 'age': 40 },
|
6979
|
+
* { 'user': 'barney', 'age': 26 },
|
6980
|
+
* { 'user': 'fred', 'age': 30 }
|
6981
|
+
* ];
|
6982
|
+
*
|
6983
|
+
* // sort by `user` in ascending order and by `age` in descending order
|
6984
|
+
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);
|
6985
|
+
* // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]]
|
6986
|
+
*/
|
6987
|
+
function sortByOrder(collection, props, orders, guard) {
|
6988
|
+
if (collection == null) {
|
6989
|
+
return [];
|
6990
|
+
}
|
6991
|
+
if (guard && isIterateeCall(props, orders, guard)) {
|
6992
|
+
orders = null;
|
6993
|
+
}
|
6994
|
+
if (!isArray(props)) {
|
6995
|
+
props = props == null ? [] : [props];
|
6996
|
+
}
|
6997
|
+
if (!isArray(orders)) {
|
6998
|
+
orders = orders == null ? [] : [orders];
|
6999
|
+
}
|
7000
|
+
return baseSortByOrder(collection, props, orders);
|
6973
7001
|
}
|
6974
7002
|
|
6975
7003
|
/**
|
@@ -7592,38 +7620,15 @@
|
|
7592
7620
|
* @returns {Function} Returns the new function.
|
7593
7621
|
* @example
|
7594
7622
|
*
|
7595
|
-
* function add(x, y) {
|
7596
|
-
* return x + y;
|
7597
|
-
* }
|
7598
|
-
*
|
7599
7623
|
* function square(n) {
|
7600
7624
|
* return n * n;
|
7601
7625
|
* }
|
7602
7626
|
*
|
7603
|
-
* var addSquare = _.flow(add, square);
|
7627
|
+
* var addSquare = _.flow(_.add, square);
|
7604
7628
|
* addSquare(1, 2);
|
7605
7629
|
* // => 9
|
7606
7630
|
*/
|
7607
|
-
|
7608
|
-
var funcs = arguments,
|
7609
|
-
length = funcs.length;
|
7610
|
-
|
7611
|
-
if (!length) {
|
7612
|
-
return function() { return arguments[0]; };
|
7613
|
-
}
|
7614
|
-
if (!arrayEvery(funcs, baseIsFunction)) {
|
7615
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
7616
|
-
}
|
7617
|
-
return function() {
|
7618
|
-
var index = 0,
|
7619
|
-
result = funcs[index].apply(this, arguments);
|
7620
|
-
|
7621
|
-
while (++index < length) {
|
7622
|
-
result = funcs[index].call(this, result);
|
7623
|
-
}
|
7624
|
-
return result;
|
7625
|
-
};
|
7626
|
-
}
|
7631
|
+
var flow = createComposer();
|
7627
7632
|
|
7628
7633
|
/**
|
7629
7634
|
* This method is like `_.flow` except that it creates a function that
|
@@ -7637,38 +7642,15 @@
|
|
7637
7642
|
* @returns {Function} Returns the new function.
|
7638
7643
|
* @example
|
7639
7644
|
*
|
7640
|
-
* function add(x, y) {
|
7641
|
-
* return x + y;
|
7642
|
-
* }
|
7643
|
-
*
|
7644
7645
|
* function square(n) {
|
7645
7646
|
* return n * n;
|
7646
7647
|
* }
|
7647
7648
|
*
|
7648
|
-
* var addSquare = _.flowRight(square, add);
|
7649
|
+
* var addSquare = _.flowRight(square, _.add);
|
7649
7650
|
* addSquare(1, 2);
|
7650
7651
|
* // => 9
|
7651
7652
|
*/
|
7652
|
-
|
7653
|
-
var funcs = arguments,
|
7654
|
-
fromIndex = funcs.length - 1;
|
7655
|
-
|
7656
|
-
if (fromIndex < 0) {
|
7657
|
-
return function() { return arguments[0]; };
|
7658
|
-
}
|
7659
|
-
if (!arrayEvery(funcs, baseIsFunction)) {
|
7660
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
7661
|
-
}
|
7662
|
-
return function() {
|
7663
|
-
var index = fromIndex,
|
7664
|
-
result = funcs[index].apply(this, arguments);
|
7665
|
-
|
7666
|
-
while (index--) {
|
7667
|
-
result = funcs[index].call(this, result);
|
7668
|
-
}
|
7669
|
-
return result;
|
7670
|
-
};
|
7671
|
-
}
|
7653
|
+
var flowRight = createComposer(true);
|
7672
7654
|
|
7673
7655
|
/**
|
7674
7656
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
@@ -7728,13 +7710,14 @@
|
|
7728
7710
|
throw new TypeError(FUNC_ERROR_TEXT);
|
7729
7711
|
}
|
7730
7712
|
var memoized = function() {
|
7731
|
-
var
|
7732
|
-
|
7713
|
+
var args = arguments,
|
7714
|
+
cache = memoized.cache,
|
7715
|
+
key = resolver ? resolver.apply(this, args) : args[0];
|
7733
7716
|
|
7734
7717
|
if (cache.has(key)) {
|
7735
7718
|
return cache.get(key);
|
7736
7719
|
}
|
7737
|
-
var result = func.apply(this,
|
7720
|
+
var result = func.apply(this, args);
|
7738
7721
|
cache.set(key, result);
|
7739
7722
|
return result;
|
7740
7723
|
};
|
@@ -8257,7 +8240,7 @@
|
|
8257
8240
|
}
|
8258
8241
|
|
8259
8242
|
/**
|
8260
|
-
* Checks if
|
8243
|
+
* Checks if `value` is empty. A value is considered empty unless it is an
|
8261
8244
|
* `arguments` object, array, string, or jQuery-like collection with a length
|
8262
8245
|
* greater than `0` or an object with own enumerable properties.
|
8263
8246
|
*
|
@@ -8875,7 +8858,7 @@
|
|
8875
8858
|
/**
|
8876
8859
|
* Assigns own enumerable properties of source object(s) to the destination
|
8877
8860
|
* object for all destination properties that resolve to `undefined`. Once a
|
8878
|
-
* property is set, additional
|
8861
|
+
* property is set, additional values of the same property are ignored.
|
8879
8862
|
*
|
8880
8863
|
* @static
|
8881
8864
|
* @memberOf _
|
@@ -9694,7 +9677,7 @@
|
|
9694
9677
|
|
9695
9678
|
/**
|
9696
9679
|
* Checks if `n` is between `start` and up to but not including, `end`. If
|
9697
|
-
* `end` is not specified it
|
9680
|
+
* `end` is not specified it is set to `start` with `start` then set to `0`.
|
9698
9681
|
*
|
9699
9682
|
* @static
|
9700
9683
|
* @memberOf _
|
@@ -9892,7 +9875,7 @@
|
|
9892
9875
|
}
|
9893
9876
|
|
9894
9877
|
/**
|
9895
|
-
* Converts the characters "&", "<", ">", '"', "'", and
|
9878
|
+
* Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to
|
9896
9879
|
* their corresponding HTML entities.
|
9897
9880
|
*
|
9898
9881
|
* **Note:** No other characters are escaped. To escape additional characters
|
@@ -10695,14 +10678,14 @@
|
|
10695
10678
|
* }
|
10696
10679
|
*/
|
10697
10680
|
function attempt() {
|
10698
|
-
var
|
10699
|
-
|
10681
|
+
var func = arguments[0],
|
10682
|
+
length = arguments.length,
|
10683
|
+
args = Array(length ? length - 1 : 0);
|
10700
10684
|
|
10685
|
+
while (--length > 0) {
|
10686
|
+
args[length - 1] = arguments[length];
|
10687
|
+
}
|
10701
10688
|
try {
|
10702
|
-
var args = Array(length ? length - 1 : 0);
|
10703
|
-
while (--length > 0) {
|
10704
|
-
args[length - 1] = arguments[length];
|
10705
|
-
}
|
10706
10689
|
return func.apply(undefined, args);
|
10707
10690
|
} catch(e) {
|
10708
10691
|
return isError(e) ? e : new Error(e);
|
@@ -11031,9 +11014,9 @@
|
|
11031
11014
|
|
11032
11015
|
/**
|
11033
11016
|
* Creates an array of numbers (positive and/or negative) progressing from
|
11034
|
-
* `start` up to, but not including, `end`. If `end` is not specified it
|
11035
|
-
*
|
11036
|
-
*
|
11017
|
+
* `start` up to, but not including, `end`. If `end` is not specified it is
|
11018
|
+
* set to `start` with `start` then set to `0`. If `start` is less than `end`
|
11019
|
+
* a zero-length range is created unless a negative `step` is specified.
|
11037
11020
|
*
|
11038
11021
|
* @static
|
11039
11022
|
* @memberOf _
|
@@ -11160,6 +11143,153 @@
|
|
11160
11143
|
|
11161
11144
|
/*------------------------------------------------------------------------*/
|
11162
11145
|
|
11146
|
+
/**
|
11147
|
+
* Adds two numbers.
|
11148
|
+
*
|
11149
|
+
* @static
|
11150
|
+
* @memberOf _
|
11151
|
+
* @category Math
|
11152
|
+
* @param {number} augend The first number to add.
|
11153
|
+
* @param {number} addend The second number to add.
|
11154
|
+
* @returns {number} Returns the sum.
|
11155
|
+
* @example
|
11156
|
+
*
|
11157
|
+
* _.add(6, 4);
|
11158
|
+
* // => 10
|
11159
|
+
*/
|
11160
|
+
function add(augend, addend) {
|
11161
|
+
return augend + addend;
|
11162
|
+
}
|
11163
|
+
|
11164
|
+
/**
|
11165
|
+
* Gets the maximum value of `collection`. If `collection` is empty or falsey
|
11166
|
+
* `-Infinity` is returned. If an iteratee function is provided it is invoked
|
11167
|
+
* for each value in `collection` to generate the criterion by which the value
|
11168
|
+
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
11169
|
+
* arguments; (value, index, collection).
|
11170
|
+
*
|
11171
|
+
* If a property name is provided for `predicate` the created `_.property`
|
11172
|
+
* style callback returns the property value of the given element.
|
11173
|
+
*
|
11174
|
+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
11175
|
+
* style callback returns `true` for elements that have a matching property
|
11176
|
+
* value, else `false`.
|
11177
|
+
*
|
11178
|
+
* If an object is provided for `predicate` the created `_.matches` style
|
11179
|
+
* callback returns `true` for elements that have the properties of the given
|
11180
|
+
* object, else `false`.
|
11181
|
+
*
|
11182
|
+
* @static
|
11183
|
+
* @memberOf _
|
11184
|
+
* @category Math
|
11185
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
11186
|
+
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
11187
|
+
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
11188
|
+
* @returns {*} Returns the maximum value.
|
11189
|
+
* @example
|
11190
|
+
*
|
11191
|
+
* _.max([4, 2, 8, 6]);
|
11192
|
+
* // => 8
|
11193
|
+
*
|
11194
|
+
* _.max([]);
|
11195
|
+
* // => -Infinity
|
11196
|
+
*
|
11197
|
+
* var users = [
|
11198
|
+
* { 'user': 'barney', 'age': 36 },
|
11199
|
+
* { 'user': 'fred', 'age': 40 }
|
11200
|
+
* ];
|
11201
|
+
*
|
11202
|
+
* _.max(users, function(chr) {
|
11203
|
+
* return chr.age;
|
11204
|
+
* });
|
11205
|
+
* // => { 'user': 'fred', 'age': 40 };
|
11206
|
+
*
|
11207
|
+
* // using the `_.property` callback shorthand
|
11208
|
+
* _.max(users, 'age');
|
11209
|
+
* // => { 'user': 'fred', 'age': 40 };
|
11210
|
+
*/
|
11211
|
+
var max = createExtremum(arrayMax);
|
11212
|
+
|
11213
|
+
/**
|
11214
|
+
* Gets the minimum value of `collection`. If `collection` is empty or falsey
|
11215
|
+
* `Infinity` is returned. If an iteratee function is provided it is invoked
|
11216
|
+
* for each value in `collection` to generate the criterion by which the value
|
11217
|
+
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
|
11218
|
+
* arguments; (value, index, collection).
|
11219
|
+
*
|
11220
|
+
* If a property name is provided for `predicate` the created `_.property`
|
11221
|
+
* style callback returns the property value of the given element.
|
11222
|
+
*
|
11223
|
+
* If a value is also provided for `thisArg` the created `_.matchesProperty`
|
11224
|
+
* style callback returns `true` for elements that have a matching property
|
11225
|
+
* value, else `false`.
|
11226
|
+
*
|
11227
|
+
* If an object is provided for `predicate` the created `_.matches` style
|
11228
|
+
* callback returns `true` for elements that have the properties of the given
|
11229
|
+
* object, else `false`.
|
11230
|
+
*
|
11231
|
+
* @static
|
11232
|
+
* @memberOf _
|
11233
|
+
* @category Math
|
11234
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
11235
|
+
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
|
11236
|
+
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
11237
|
+
* @returns {*} Returns the minimum value.
|
11238
|
+
* @example
|
11239
|
+
*
|
11240
|
+
* _.min([4, 2, 8, 6]);
|
11241
|
+
* // => 2
|
11242
|
+
*
|
11243
|
+
* _.min([]);
|
11244
|
+
* // => Infinity
|
11245
|
+
*
|
11246
|
+
* var users = [
|
11247
|
+
* { 'user': 'barney', 'age': 36 },
|
11248
|
+
* { 'user': 'fred', 'age': 40 }
|
11249
|
+
* ];
|
11250
|
+
*
|
11251
|
+
* _.min(users, function(chr) {
|
11252
|
+
* return chr.age;
|
11253
|
+
* });
|
11254
|
+
* // => { 'user': 'barney', 'age': 36 };
|
11255
|
+
*
|
11256
|
+
* // using the `_.property` callback shorthand
|
11257
|
+
* _.min(users, 'age');
|
11258
|
+
* // => { 'user': 'barney', 'age': 36 };
|
11259
|
+
*/
|
11260
|
+
var min = createExtremum(arrayMin, true);
|
11261
|
+
|
11262
|
+
/**
|
11263
|
+
* Gets the sum of the values in `collection`.
|
11264
|
+
*
|
11265
|
+
* @static
|
11266
|
+
* @memberOf _
|
11267
|
+
* @category Math
|
11268
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
11269
|
+
* @returns {number} Returns the sum.
|
11270
|
+
* @example
|
11271
|
+
*
|
11272
|
+
* _.sum([4, 6, 2]);
|
11273
|
+
* // => 12
|
11274
|
+
*
|
11275
|
+
* _.sum({ 'a': 4, 'b': 6, 'c': 2 });
|
11276
|
+
* // => 12
|
11277
|
+
*/
|
11278
|
+
function sum(collection) {
|
11279
|
+
if (!isArray(collection)) {
|
11280
|
+
collection = toIterable(collection);
|
11281
|
+
}
|
11282
|
+
var length = collection.length,
|
11283
|
+
result = 0;
|
11284
|
+
|
11285
|
+
while (length--) {
|
11286
|
+
result += +collection[length] || 0;
|
11287
|
+
}
|
11288
|
+
return result;
|
11289
|
+
}
|
11290
|
+
|
11291
|
+
/*------------------------------------------------------------------------*/
|
11292
|
+
|
11163
11293
|
// Ensure wrappers are instances of `baseLodash`.
|
11164
11294
|
lodash.prototype = baseLodash.prototype;
|
11165
11295
|
|
@@ -11258,6 +11388,7 @@
|
|
11258
11388
|
lodash.slice = slice;
|
11259
11389
|
lodash.sortBy = sortBy;
|
11260
11390
|
lodash.sortByAll = sortByAll;
|
11391
|
+
lodash.sortByOrder = sortByOrder;
|
11261
11392
|
lodash.spread = spread;
|
11262
11393
|
lodash.take = take;
|
11263
11394
|
lodash.takeRight = takeRight;
|
@@ -11302,6 +11433,7 @@
|
|
11302
11433
|
/*------------------------------------------------------------------------*/
|
11303
11434
|
|
11304
11435
|
// Add functions that return unwrapped values when chaining.
|
11436
|
+
lodash.add = add;
|
11305
11437
|
lodash.attempt = attempt;
|
11306
11438
|
lodash.camelCase = camelCase;
|
11307
11439
|
lodash.capitalize = capitalize;
|
@@ -11371,6 +11503,7 @@
|
|
11371
11503
|
lodash.sortedLastIndex = sortedLastIndex;
|
11372
11504
|
lodash.startCase = startCase;
|
11373
11505
|
lodash.startsWith = startsWith;
|
11506
|
+
lodash.sum = sum;
|
11374
11507
|
lodash.template = template;
|
11375
11508
|
lodash.trim = trim;
|
11376
11509
|
lodash.trimLeft = trimLeft;
|
@@ -11432,15 +11565,17 @@
|
|
11432
11565
|
});
|
11433
11566
|
|
11434
11567
|
// Add `LazyWrapper` methods that accept an `iteratee` value.
|
11435
|
-
arrayEach(['filter', 'map', 'takeWhile'], function(methodName,
|
11436
|
-
var isFilter =
|
11568
|
+
arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) {
|
11569
|
+
var isFilter = type != LAZY_MAP_FLAG,
|
11570
|
+
isDropWhile = type == LAZY_DROP_WHILE_FLAG;
|
11437
11571
|
|
11438
11572
|
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
11439
|
-
var
|
11573
|
+
var filtered = this.__filtered__,
|
11574
|
+
result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(),
|
11440
11575
|
iteratees = result.__iteratees__ || (result.__iteratees__ = []);
|
11441
11576
|
|
11442
|
-
result.__filtered__ =
|
11443
|
-
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg,
|
11577
|
+
result.__filtered__ = filtered || isFilter;
|
11578
|
+
iteratees.push({ 'done': false, 'index': 0, 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type });
|
11444
11579
|
return result;
|
11445
11580
|
};
|
11446
11581
|
});
|
@@ -11505,23 +11640,10 @@
|
|
11505
11640
|
return this.filter(identity);
|
11506
11641
|
};
|
11507
11642
|
|
11508
|
-
LazyWrapper.prototype.dropWhile = function(predicate, thisArg) {
|
11509
|
-
var done,
|
11510
|
-
lastIndex,
|
11511
|
-
isRight = this.__dir__ < 0;
|
11512
|
-
|
11513
|
-
predicate = getCallback(predicate, thisArg, 3);
|
11514
|
-
return this.filter(function(value, index, array) {
|
11515
|
-
done = done && (isRight ? index < lastIndex : index > lastIndex);
|
11516
|
-
lastIndex = index;
|
11517
|
-
return done || (done = !predicate(value, index, array));
|
11518
|
-
});
|
11519
|
-
};
|
11520
|
-
|
11521
11643
|
LazyWrapper.prototype.reject = function(predicate, thisArg) {
|
11522
|
-
predicate = getCallback(predicate, thisArg,
|
11523
|
-
return this.filter(function(value
|
11524
|
-
return !predicate(value
|
11644
|
+
predicate = getCallback(predicate, thisArg, 1);
|
11645
|
+
return this.filter(function(value) {
|
11646
|
+
return !predicate(value);
|
11525
11647
|
});
|
11526
11648
|
};
|
11527
11649
|
|
@@ -11543,16 +11665,24 @@
|
|
11543
11665
|
// Add `LazyWrapper` methods to `lodash.prototype`.
|
11544
11666
|
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
11545
11667
|
var lodashFunc = lodash[methodName],
|
11668
|
+
checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
|
11546
11669
|
retUnwrapped = /^(?:first|last)$/.test(methodName);
|
11547
11670
|
|
11548
11671
|
lodash.prototype[methodName] = function() {
|
11549
|
-
var
|
11550
|
-
|
11672
|
+
var args = arguments,
|
11673
|
+
length = args.length,
|
11551
11674
|
chainAll = this.__chain__,
|
11675
|
+
value = this.__wrapped__,
|
11552
11676
|
isHybrid = !!this.__actions__.length,
|
11553
11677
|
isLazy = value instanceof LazyWrapper,
|
11554
|
-
|
11678
|
+
iteratee = args[0],
|
11679
|
+
useLazy = isLazy || isArray(value);
|
11555
11680
|
|
11681
|
+
if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
|
11682
|
+
// avoid lazy use if the iteratee has a `length` other than `1`
|
11683
|
+
isLazy = useLazy = false;
|
11684
|
+
}
|
11685
|
+
var onlyLazy = isLazy && !isHybrid;
|
11556
11686
|
if (retUnwrapped && !chainAll) {
|
11557
11687
|
return onlyLazy
|
11558
11688
|
? func.call(value)
|
@@ -11563,7 +11693,7 @@
|
|
11563
11693
|
push.apply(otherArgs, args);
|
11564
11694
|
return lodashFunc.apply(lodash, otherArgs);
|
11565
11695
|
};
|
11566
|
-
if (
|
11696
|
+
if (useLazy) {
|
11567
11697
|
var wrapper = onlyLazy ? value : new LazyWrapper(this),
|
11568
11698
|
result = func.apply(wrapper, args);
|
11569
11699
|
|