lodash-rails 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a756b907ca33eaa88a11859c199c1a1873c63dc9
4
- data.tar.gz: 3f594e06e1f78943db49d1096efeac2384978359
3
+ metadata.gz: 369716b2bb1fae0f2112697dd79b425bbfee483f
4
+ data.tar.gz: 4901ab398ff33011c875760f03a3b9d7267378a1
5
5
  SHA512:
6
- metadata.gz: baa0622398f5e249fa69907fb24819913cf3276e85ca4adc547b3cb58beca82041ba984ed6559f2502764bbc7a5ddc95084fcd1f03c0417f3543754810f5a99c
7
- data.tar.gz: de4f51e5f4aa7579bff87d4f70b86ae6482473ca4407169cafc0423871a3ea5b30d1b2633f448f96c0e3d619c9259c7a39cf5a31787a2fd8bedbf7d54a9c7149
6
+ metadata.gz: 7ba51e2184c6dbfc56d7e97e3ac4af1f50b8bfeda62d848c82f1650fb52e03db5bb68c8b43d153c54bcec3866c4ff8d9e4236ef819cd8b816b3d6dfe7ab0b5ab
7
+ data.tar.gz: bbaf1d78b8a5881f48eeb6c9748ed6be68da48d7b90913baf2c64f7c95adf0b528dcc5181f462f611c3442a817d28a883476012bdef9fbc05893682c69e55162
data/README.md CHANGED
@@ -18,7 +18,7 @@ Add the necessary library to `app/assets/javascripts/application.js`:
18
18
 
19
19
  ## What's included?
20
20
 
21
- lodash 3.5.0:
21
+ lodash 3.6.0:
22
22
 
23
23
  * lodash.js
24
24
  * lodash.min.js
@@ -1,5 +1,5 @@
1
1
  module LoDash
2
2
  module Rails
3
- VERSION = "3.5.0"
3
+ VERSION = "3.6.0"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * lodash 3.5.0 (Custom Build) <https://lodash.com/>
3
+ * lodash 3.6.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.5.0';
16
+ var VERSION = '3.6.0';
17
17
 
18
18
  /** Used to compose bitmasks for wrapper metadata. */
19
19
  var BIND_FLAG = 1,
@@ -23,8 +23,8 @@
23
23
  CURRY_RIGHT_FLAG = 16,
24
24
  PARTIAL_FLAG = 32,
25
25
  PARTIAL_RIGHT_FLAG = 64,
26
- REARG_FLAG = 128,
27
- ARY_FLAG = 256;
26
+ ARY_FLAG = 128,
27
+ REARG_FLAG = 256;
28
28
 
29
29
  /** Used as default options for `_.trunc`. */
30
30
  var DEFAULT_TRUNC_LENGTH = 30,
@@ -88,18 +88,18 @@
88
88
  reInterpolate = /<%=([\s\S]+?)%>/g;
89
89
 
90
90
  /**
91
- * Used to match ES template delimiters.
92
- * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components)
93
- * for more details.
91
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
92
+ */
93
+ var reComboMarks = /[\u0300-\u036f\ufe20-\ufe23]/g;
94
+
95
+ /**
96
+ * Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components).
94
97
  */
95
98
  var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
96
99
 
97
100
  /** Used to match `RegExp` flags from their coerced string values. */
98
101
  var reFlags = /\w*$/;
99
102
 
100
- /** Used to detect named functions. */
101
- var reFuncName = /^\s*function[ \n\r\t]+\w/;
102
-
103
103
  /** Used to detect hexadecimal string values. */
104
104
  var reHexPrefix = /^0[xX]/;
105
105
 
@@ -113,16 +113,13 @@
113
113
  var reNoMatch = /($^)/;
114
114
 
115
115
  /**
116
- * Used to match `RegExp` special characters.
117
- * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special)
118
- * for more details.
116
+ * Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
117
+ * In addition to special characters the forward slash is escaped to allow for
118
+ * easier `eval` use and `Function` compilation.
119
119
  */
120
120
  var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
121
121
  reHasRegExpChars = RegExp(reRegExpChars.source);
122
122
 
123
- /** Used to detect functions containing a `this` reference. */
124
- var reThis = /\bthis\b/;
125
-
126
123
  /** Used to match unescaped characters in compiled string literals. */
127
124
  var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
128
125
 
@@ -153,7 +150,7 @@
153
150
  'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document',
154
151
  'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',
155
152
  'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
156
- 'window', 'WinRTError'
153
+ 'window'
157
154
  ];
158
155
 
159
156
  /** Used to fix the JScript `[[DontEnum]]` bug. */
@@ -268,8 +265,11 @@
268
265
  /** Detect free variable `global` from Node.js. */
269
266
  var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
270
267
 
268
+ /** Detect free variable `self`. */
269
+ var freeSelf = objectTypes[typeof self] && self && self.Object && self;
270
+
271
271
  /** Detect free variable `window`. */
272
- var freeWindow = objectTypes[typeof window] && window;
272
+ var freeWindow = objectTypes[typeof window] && window && window.Object && window;
273
273
 
274
274
  /** Detect the popular CommonJS extension `module.exports`. */
275
275
  var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
@@ -280,7 +280,7 @@
280
280
  * The `this` value is used if it is the global object to avoid Greasemonkey's
281
281
  * restricted `window` object, otherwise the `window` object is used.
282
282
  */
283
- var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this;
283
+ var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
284
284
 
285
285
  /*--------------------------------------------------------------------------*/
286
286
 
@@ -308,6 +308,28 @@
308
308
  return 0;
309
309
  }
310
310
 
311
+ /**
312
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
313
+ * support for callback shorthands and `this` binding.
314
+ *
315
+ * @private
316
+ * @param {Array} array The array to search.
317
+ * @param {Function} predicate The function invoked per iteration.
318
+ * @param {boolean} [fromRight] Specify iterating from right to left.
319
+ * @returns {number} Returns the index of the matched value, else `-1`.
320
+ */
321
+ function baseFindIndex(array, predicate, fromRight) {
322
+ var length = array.length,
323
+ index = fromRight ? length : -1;
324
+
325
+ while ((fromRight ? index-- : ++index < length)) {
326
+ if (predicate(array[index], index, array)) {
327
+ return index;
328
+ }
329
+ }
330
+ return -1;
331
+ }
332
+
311
333
  /**
312
334
  * The base implementation of `_.indexOf` without support for binary searches.
313
335
  *
@@ -494,7 +516,6 @@
494
516
 
495
517
  /**
496
518
  * Gets the index at which the first occurrence of `NaN` is found in `array`.
497
- * If `fromRight` is provided elements of `array` are iterated from right to left.
498
519
  *
499
520
  * @private
500
521
  * @param {Array} array The array to search.
@@ -543,7 +564,7 @@
543
564
  * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
544
565
  */
545
566
  function isObjectLike(value) {
546
- return (value && typeof value == 'object') || false;
567
+ return !!value && typeof value == 'object';
547
568
  }
548
569
 
549
570
  /**
@@ -665,19 +686,19 @@
665
686
  * @returns {Function} Returns a new `lodash` function.
666
687
  * @example
667
688
  *
668
- * _.mixin({ 'add': function(a, b) { return a + b; } });
689
+ * _.mixin({ 'foo': _.constant('foo') });
669
690
  *
670
691
  * var lodash = _.runInContext();
671
- * lodash.mixin({ 'sub': function(a, b) { return a - b; } });
692
+ * lodash.mixin({ 'bar': lodash.constant('bar') });
672
693
  *
673
- * _.isFunction(_.add);
694
+ * _.isFunction(_.foo);
674
695
  * // => true
675
- * _.isFunction(_.sub);
696
+ * _.isFunction(_.bar);
676
697
  * // => false
677
698
  *
678
- * lodash.isFunction(lodash.add);
699
+ * lodash.isFunction(lodash.foo);
679
700
  * // => false
680
- * lodash.isFunction(lodash.sub);
701
+ * lodash.isFunction(lodash.bar);
681
702
  * // => true
682
703
  *
683
704
  * // using `context` to mock `Date#getTime` use in `_.now`
@@ -731,9 +752,8 @@
731
752
  var idCounter = 0;
732
753
 
733
754
  /**
734
- * Used to resolve the `toStringTag` of values.
735
- * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
736
- * for more details.
755
+ * Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
756
+ * of values.
737
757
  */
738
758
  var objToString = objectProto.toString;
739
759
 
@@ -798,15 +818,17 @@
798
818
  var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
799
819
 
800
820
  /**
801
- * Used as the maximum length of an array-like value.
802
- * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
803
- * for more details.
821
+ * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
822
+ * of an array-like value.
804
823
  */
805
824
  var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
806
825
 
807
826
  /** Used to store function metadata. */
808
827
  var metaMap = WeakMap && new WeakMap;
809
828
 
829
+ /** Used to lookup unminified function names. */
830
+ var realNames = {};
831
+
810
832
  /** Used to lookup a type array constructors by `toStringTag`. */
811
833
  var ctorByTag = {};
812
834
  ctorByTag[float32Tag] = context.Float32Array;
@@ -1022,7 +1044,7 @@
1022
1044
  * @memberOf _.support
1023
1045
  * @type boolean
1024
1046
  */
1025
- support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext);
1047
+ support.funcDecomp = /\bthis\b/.test(function() { return this; });
1026
1048
 
1027
1049
  /**
1028
1050
  * Detect if `Function#name` is supported (all but IE).
@@ -1461,7 +1483,7 @@
1461
1483
 
1462
1484
  /**
1463
1485
  * A specialized version of `_.forEach` for arrays without support for callback
1464
- * shorthands or `this` binding.
1486
+ * shorthands and `this` binding.
1465
1487
  *
1466
1488
  * @private
1467
1489
  * @param {Array} array The array to iterate over.
@@ -1482,7 +1504,7 @@
1482
1504
 
1483
1505
  /**
1484
1506
  * A specialized version of `_.forEachRight` for arrays without support for
1485
- * callback shorthands or `this` binding.
1507
+ * callback shorthands and `this` binding.
1486
1508
  *
1487
1509
  * @private
1488
1510
  * @param {Array} array The array to iterate over.
@@ -1502,7 +1524,7 @@
1502
1524
 
1503
1525
  /**
1504
1526
  * A specialized version of `_.every` for arrays without support for callback
1505
- * shorthands or `this` binding.
1527
+ * shorthands and `this` binding.
1506
1528
  *
1507
1529
  * @private
1508
1530
  * @param {Array} array The array to iterate over.
@@ -1524,7 +1546,7 @@
1524
1546
 
1525
1547
  /**
1526
1548
  * A specialized version of `_.filter` for arrays without support for callback
1527
- * shorthands or `this` binding.
1549
+ * shorthands and `this` binding.
1528
1550
  *
1529
1551
  * @private
1530
1552
  * @param {Array} array The array to iterate over.
@@ -1548,7 +1570,7 @@
1548
1570
 
1549
1571
  /**
1550
1572
  * A specialized version of `_.map` for arrays without support for callback
1551
- * shorthands or `this` binding.
1573
+ * shorthands and `this` binding.
1552
1574
  *
1553
1575
  * @private
1554
1576
  * @param {Array} array The array to iterate over.
@@ -1610,7 +1632,7 @@
1610
1632
 
1611
1633
  /**
1612
1634
  * A specialized version of `_.reduce` for arrays without support for callback
1613
- * shorthands or `this` binding.
1635
+ * shorthands and `this` binding.
1614
1636
  *
1615
1637
  * @private
1616
1638
  * @param {Array} array The array to iterate over.
@@ -1635,7 +1657,7 @@
1635
1657
 
1636
1658
  /**
1637
1659
  * A specialized version of `_.reduceRight` for arrays without support for
1638
- * callback shorthands or `this` binding.
1660
+ * callback shorthands and `this` binding.
1639
1661
  *
1640
1662
  * @private
1641
1663
  * @param {Array} array The array to iterate over.
@@ -1658,7 +1680,7 @@
1658
1680
 
1659
1681
  /**
1660
1682
  * A specialized version of `_.some` for arrays without support for callback
1661
- * shorthands or `this` binding.
1683
+ * shorthands and `this` binding.
1662
1684
  *
1663
1685
  * @private
1664
1686
  * @param {Array} array The array to iterate over.
@@ -1678,6 +1700,23 @@
1678
1700
  return false;
1679
1701
  }
1680
1702
 
1703
+ /**
1704
+ * A specialized version of `_.sum` for arrays without support for iteratees.
1705
+ *
1706
+ * @private
1707
+ * @param {Array} array The array to iterate over.
1708
+ * @returns {number} Returns the sum.
1709
+ */
1710
+ function arraySum(array) {
1711
+ var length = array.length,
1712
+ result = 0;
1713
+
1714
+ while (length--) {
1715
+ result += +array[length] || 0;
1716
+ }
1717
+ return result;
1718
+ }
1719
+
1681
1720
  /**
1682
1721
  * Used by `_.defaults` to customize its `_.assign` use.
1683
1722
  *
@@ -1792,26 +1831,6 @@
1792
1831
  return object;
1793
1832
  }
1794
1833
 
1795
- /**
1796
- * The base implementation of `_.bindAll` without support for individual
1797
- * method name arguments.
1798
- *
1799
- * @private
1800
- * @param {Object} object The object to bind and assign the bound methods to.
1801
- * @param {string[]} methodNames The object method names to bind.
1802
- * @returns {Object} Returns `object`.
1803
- */
1804
- function baseBindAll(object, methodNames) {
1805
- var index = -1,
1806
- length = methodNames.length;
1807
-
1808
- while (++index < length) {
1809
- var key = methodNames[index];
1810
- object[key] = createWrapper(object[key], BIND_FLAG, object);
1811
- }
1812
- return object;
1813
- }
1814
-
1815
1834
  /**
1816
1835
  * The base implementation of `_.callback` which supports specifying the
1817
1836
  * number of arguments to provide to `func`.
@@ -1825,9 +1844,9 @@
1825
1844
  function baseCallback(func, thisArg, argCount) {
1826
1845
  var type = typeof func;
1827
1846
  if (type == 'function') {
1828
- return (typeof thisArg != 'undefined' && isBindable(func))
1829
- ? bindCallback(func, thisArg, argCount)
1830
- : func;
1847
+ return typeof thisArg == 'undefined'
1848
+ ? func
1849
+ : bindCallback(func, thisArg, argCount);
1831
1850
  }
1832
1851
  if (func == null) {
1833
1852
  return identity;
@@ -1937,14 +1956,14 @@
1937
1956
  * @private
1938
1957
  * @param {Function} func The function to delay.
1939
1958
  * @param {number} wait The number of milliseconds to delay invocation.
1940
- * @param {Object} args The `arguments` object to slice and provide to `func`.
1959
+ * @param {Object} args The arguments provide to `func`.
1941
1960
  * @returns {number} Returns the timer id.
1942
1961
  */
1943
- function baseDelay(func, wait, args, fromIndex) {
1962
+ function baseDelay(func, wait, args) {
1944
1963
  if (typeof func != 'function') {
1945
1964
  throw new TypeError(FUNC_ERROR_TEXT);
1946
1965
  }
1947
- return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait);
1966
+ return setTimeout(function() { func.apply(undefined, args); }, wait);
1948
1967
  }
1949
1968
 
1950
1969
  /**
@@ -2003,21 +2022,7 @@
2003
2022
  * @param {Function} iteratee The function invoked per iteration.
2004
2023
  * @returns {Array|Object|string} Returns `collection`.
2005
2024
  */
2006
- function baseEach(collection, iteratee) {
2007
- var length = collection ? collection.length : 0;
2008
- if (!isLength(length)) {
2009
- return baseForOwn(collection, iteratee);
2010
- }
2011
- var index = -1,
2012
- iterable = toObject(collection);
2013
-
2014
- while (++index < length) {
2015
- if (iteratee(iterable[index], index, iterable) === false) {
2016
- break;
2017
- }
2018
- }
2019
- return collection;
2020
- }
2025
+ var baseEach = createBaseEach(baseForOwn);
2021
2026
 
2022
2027
  /**
2023
2028
  * The base implementation of `_.forEachRight` without support for callback
@@ -2028,23 +2033,11 @@
2028
2033
  * @param {Function} iteratee The function invoked per iteration.
2029
2034
  * @returns {Array|Object|string} Returns `collection`.
2030
2035
  */
2031
- function baseEachRight(collection, iteratee) {
2032
- var length = collection ? collection.length : 0;
2033
- if (!isLength(length)) {
2034
- return baseForOwnRight(collection, iteratee);
2035
- }
2036
- var iterable = toObject(collection);
2037
- while (length--) {
2038
- if (iteratee(iterable[length], length, iterable) === false) {
2039
- break;
2040
- }
2041
- }
2042
- return collection;
2043
- }
2036
+ var baseEachRight = createBaseEach(baseForOwnRight, true);
2044
2037
 
2045
2038
  /**
2046
2039
  * The base implementation of `_.every` without support for callback
2047
- * shorthands or `this` binding.
2040
+ * shorthands and `this` binding.
2048
2041
  *
2049
2042
  * @private
2050
2043
  * @param {Array|Object|string} collection The collection to iterate over.
@@ -2093,7 +2086,7 @@
2093
2086
 
2094
2087
  /**
2095
2088
  * The base implementation of `_.filter` without support for callback
2096
- * shorthands or `this` binding.
2089
+ * shorthands and `this` binding.
2097
2090
  *
2098
2091
  * @private
2099
2092
  * @param {Array|Object|string} collection The collection to iterate over.
@@ -2142,11 +2135,10 @@
2142
2135
  * @param {Array} array The array to flatten.
2143
2136
  * @param {boolean} isDeep Specify a deep flatten.
2144
2137
  * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
2145
- * @param {number} fromIndex The index to start from.
2146
2138
  * @returns {Array} Returns the new flattened array.
2147
2139
  */
2148
- function baseFlatten(array, isDeep, isStrict, fromIndex) {
2149
- var index = fromIndex - 1,
2140
+ function baseFlatten(array, isDeep, isStrict) {
2141
+ var index = -1,
2150
2142
  length = array.length,
2151
2143
  resIndex = -1,
2152
2144
  result = [];
@@ -2157,7 +2149,7 @@
2157
2149
  if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
2158
2150
  if (isDeep) {
2159
2151
  // Recursively flatten arrays (susceptible to call stack limits).
2160
- value = baseFlatten(value, isDeep, isStrict, 0);
2152
+ value = baseFlatten(value, isDeep, isStrict);
2161
2153
  }
2162
2154
  var valIndex = -1,
2163
2155
  valLength = value.length;
@@ -2185,20 +2177,7 @@
2185
2177
  * @param {Function} keysFunc The function to get the keys of `object`.
2186
2178
  * @returns {Object} Returns `object`.
2187
2179
  */
2188
- function baseFor(object, iteratee, keysFunc) {
2189
- var index = -1,
2190
- iterable = toObject(object),
2191
- props = keysFunc(object),
2192
- length = props.length;
2193
-
2194
- while (++index < length) {
2195
- var key = props[index];
2196
- if (iteratee(iterable[key], key, iterable) === false) {
2197
- break;
2198
- }
2199
- }
2200
- return object;
2201
- }
2180
+ var baseFor = createBaseFor();
2202
2181
 
2203
2182
  /**
2204
2183
  * This function is like `baseFor` except that it iterates over properties
@@ -2210,19 +2189,7 @@
2210
2189
  * @param {Function} keysFunc The function to get the keys of `object`.
2211
2190
  * @returns {Object} Returns `object`.
2212
2191
  */
2213
- function baseForRight(object, iteratee, keysFunc) {
2214
- var iterable = toObject(object),
2215
- props = keysFunc(object),
2216
- length = props.length;
2217
-
2218
- while (length--) {
2219
- var key = props[length];
2220
- if (iteratee(iterable[key], key, iterable) === false) {
2221
- break;
2222
- }
2223
- }
2224
- return object;
2225
- }
2192
+ var baseForRight = createBaseFor(true);
2226
2193
 
2227
2194
  /**
2228
2195
  * The base implementation of `_.forIn` without support for callback
@@ -2287,30 +2254,6 @@
2287
2254
  return result;
2288
2255
  }
2289
2256
 
2290
- /**
2291
- * The base implementation of `_.invoke` which requires additional arguments
2292
- * to be provided as an array of arguments rather than individually.
2293
- *
2294
- * @private
2295
- * @param {Array|Object|string} collection The collection to iterate over.
2296
- * @param {Function|string} methodName The name of the method to invoke or
2297
- * the function invoked per iteration.
2298
- * @param {Array} [args] The arguments to invoke the method with.
2299
- * @returns {Array} Returns the array of results.
2300
- */
2301
- function baseInvoke(collection, methodName, args) {
2302
- var index = -1,
2303
- isFunc = typeof methodName == 'function',
2304
- length = collection ? collection.length : 0,
2305
- result = isLength(length) ? Array(length) : [];
2306
-
2307
- baseEach(collection, function(value) {
2308
- var func = isFunc ? methodName : (value != null && value[methodName]);
2309
- result[++index] = func ? func.apply(value, args) : undefined;
2310
- });
2311
- return result;
2312
- }
2313
-
2314
2257
  /**
2315
2258
  * The base implementation of `_.isEqual` without support for `this` binding
2316
2259
  * `customizer` functions.
@@ -2319,12 +2262,12 @@
2319
2262
  * @param {*} value The value to compare.
2320
2263
  * @param {*} other The other value to compare.
2321
2264
  * @param {Function} [customizer] The function to customize comparing values.
2322
- * @param {boolean} [isWhere] Specify performing partial comparisons.
2265
+ * @param {boolean} [isLoose] Specify performing partial comparisons.
2323
2266
  * @param {Array} [stackA] Tracks traversed `value` objects.
2324
2267
  * @param {Array} [stackB] Tracks traversed `other` objects.
2325
2268
  * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2326
2269
  */
2327
- function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) {
2270
+ function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
2328
2271
  // Exit early for identical values.
2329
2272
  if (value === other) {
2330
2273
  // Treat `+0` vs. `-0` as not equal.
@@ -2339,7 +2282,7 @@
2339
2282
  // Return `false` unless both values are `NaN`.
2340
2283
  return value !== value && other !== other;
2341
2284
  }
2342
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, isWhere, stackA, stackB);
2285
+ return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
2343
2286
  }
2344
2287
 
2345
2288
  /**
@@ -2352,12 +2295,12 @@
2352
2295
  * @param {Object} other The other object to compare.
2353
2296
  * @param {Function} equalFunc The function to determine equivalents of values.
2354
2297
  * @param {Function} [customizer] The function to customize comparing objects.
2355
- * @param {boolean} [isWhere] Specify performing partial comparisons.
2298
+ * @param {boolean} [isLoose] Specify performing partial comparisons.
2356
2299
  * @param {Array} [stackA=[]] Tracks traversed `value` objects.
2357
2300
  * @param {Array} [stackB=[]] Tracks traversed `other` objects.
2358
2301
  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2359
2302
  */
2360
- function baseIsEqualDeep(object, other, equalFunc, customizer, isWhere, stackA, stackB) {
2303
+ function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
2361
2304
  var objIsArr = isArray(object),
2362
2305
  othIsArr = isArray(other),
2363
2306
  objTag = arrayTag,
@@ -2379,21 +2322,27 @@
2379
2322
  othIsArr = isTypedArray(other);
2380
2323
  }
2381
2324
  }
2382
- var objIsObj = objTag == objectTag && !isHostObject(object),
2383
- othIsObj = othTag == objectTag && !isHostObject(other),
2325
+ var objIsObj = (objTag == objectTag || (isLoose && objTag == funcTag)) && !isHostObject(object),
2326
+ othIsObj = (othTag == objectTag || (isLoose && othTag == funcTag)) && !isHostObject(other),
2384
2327
  isSameTag = objTag == othTag;
2385
2328
 
2386
2329
  if (isSameTag && !(objIsArr || objIsObj)) {
2387
2330
  return equalByTag(object, other, objTag);
2388
2331
  }
2389
- var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2390
- othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2332
+ if (isLoose) {
2333
+ if (!isSameTag && !(objIsObj && othIsObj)) {
2334
+ return false;
2335
+ }
2336
+ } else {
2337
+ var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2338
+ othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2391
2339
 
2392
- if (valWrapped || othWrapped) {
2393
- return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isWhere, stackA, stackB);
2394
- }
2395
- if (!isSameTag) {
2396
- return false;
2340
+ if (valWrapped || othWrapped) {
2341
+ return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
2342
+ }
2343
+ if (!isSameTag) {
2344
+ return false;
2345
+ }
2397
2346
  }
2398
2347
  // Assume cyclic values are equal.
2399
2348
  // For more information on detecting circular references see https://es5.github.io/#JO.
@@ -2410,7 +2359,7 @@
2410
2359
  stackA.push(object);
2411
2360
  stackB.push(other);
2412
2361
 
2413
- var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isWhere, stackA, stackB);
2362
+ var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
2414
2363
 
2415
2364
  stackA.pop();
2416
2365
  stackB.pop();
@@ -2420,7 +2369,7 @@
2420
2369
 
2421
2370
  /**
2422
2371
  * The base implementation of `_.isMatch` without support for callback
2423
- * shorthands or `this` binding.
2372
+ * shorthands and `this` binding.
2424
2373
  *
2425
2374
  * @private
2426
2375
  * @param {Object} object The object to inspect.
@@ -2431,30 +2380,27 @@
2431
2380
  * @returns {boolean} Returns `true` if `object` is a match, else `false`.
2432
2381
  */
2433
2382
  function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
2434
- var length = props.length;
2435
- if (object == null) {
2436
- return !length;
2437
- }
2438
2383
  var index = -1,
2384
+ length = props.length,
2439
2385
  noCustomizer = !customizer;
2440
2386
 
2441
2387
  while (++index < length) {
2442
2388
  if ((noCustomizer && strictCompareFlags[index])
2443
2389
  ? values[index] !== object[props[index]]
2444
- : !hasOwnProperty.call(object, props[index])
2390
+ : !(props[index] in object)
2445
2391
  ) {
2446
2392
  return false;
2447
2393
  }
2448
2394
  }
2449
2395
  index = -1;
2450
2396
  while (++index < length) {
2451
- var key = props[index];
2397
+ var key = props[index],
2398
+ objValue = object[key],
2399
+ srcValue = values[index];
2400
+
2452
2401
  if (noCustomizer && strictCompareFlags[index]) {
2453
- var result = hasOwnProperty.call(object, key);
2402
+ var result = typeof objValue != 'undefined' || (key in object);
2454
2403
  } else {
2455
- var objValue = object[key],
2456
- srcValue = values[index];
2457
-
2458
2404
  result = customizer ? customizer(objValue, srcValue, key) : undefined;
2459
2405
  if (typeof result == 'undefined') {
2460
2406
  result = baseIsEqual(srcValue, objValue, customizer, true);
@@ -2469,7 +2415,7 @@
2469
2415
 
2470
2416
  /**
2471
2417
  * The base implementation of `_.map` without support for callback shorthands
2472
- * or `this` binding.
2418
+ * and `this` binding.
2473
2419
  *
2474
2420
  * @private
2475
2421
  * @param {Array|Object|string} collection The collection to iterate over.
@@ -2495,13 +2441,17 @@
2495
2441
  var props = keys(source),
2496
2442
  length = props.length;
2497
2443
 
2444
+ if (!length) {
2445
+ return constant(true);
2446
+ }
2498
2447
  if (length == 1) {
2499
2448
  var key = props[0],
2500
2449
  value = source[key];
2501
2450
 
2502
2451
  if (isStrictComparable(value)) {
2503
2452
  return function(object) {
2504
- return object != null && object[key] === value && hasOwnProperty.call(object, key);
2453
+ return object != null && object[key] === value &&
2454
+ (typeof value != 'undefined' || (key in toObject(object)));
2505
2455
  };
2506
2456
  }
2507
2457
  }
@@ -2514,7 +2464,7 @@
2514
2464
  strictCompareFlags[length] = isStrictComparable(value);
2515
2465
  }
2516
2466
  return function(object) {
2517
- return baseIsMatch(object, props, values, strictCompareFlags);
2467
+ return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
2518
2468
  };
2519
2469
  }
2520
2470
 
@@ -2530,7 +2480,8 @@
2530
2480
  function baseMatchesProperty(key, value) {
2531
2481
  if (isStrictComparable(value)) {
2532
2482
  return function(object) {
2533
- return object != null && object[key] === value;
2483
+ return object != null && object[key] === value &&
2484
+ (typeof value != 'undefined' || (key in toObject(object)));
2534
2485
  };
2535
2486
  }
2536
2487
  return function(object) {
@@ -2610,7 +2561,7 @@
2610
2561
  if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
2611
2562
  result = isArray(value)
2612
2563
  ? value
2613
- : (value ? arrayCopy(value) : []);
2564
+ : ((value && value.length) ? arrayCopy(value) : []);
2614
2565
  }
2615
2566
  else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2616
2567
  result = isArguments(value)
@@ -2647,30 +2598,6 @@
2647
2598
  };
2648
2599
  }
2649
2600
 
2650
- /**
2651
- * The base implementation of `_.pullAt` without support for individual
2652
- * index arguments.
2653
- *
2654
- * @private
2655
- * @param {Array} array The array to modify.
2656
- * @param {number[]} indexes The indexes of elements to remove.
2657
- * @returns {Array} Returns the new array of removed elements.
2658
- */
2659
- function basePullAt(array, indexes) {
2660
- var length = indexes.length,
2661
- result = baseAt(array, indexes);
2662
-
2663
- indexes.sort(baseCompareAscending);
2664
- while (length--) {
2665
- var index = parseFloat(indexes[length]);
2666
- if (index != previous && isIndex(index)) {
2667
- var previous = index;
2668
- splice.call(array, index, 1);
2669
- }
2670
- }
2671
- return result;
2672
- }
2673
-
2674
2601
  /**
2675
2602
  * The base implementation of `_.random` without support for argument juggling
2676
2603
  * and returning floating-point numbers.
@@ -2686,7 +2613,7 @@
2686
2613
 
2687
2614
  /**
2688
2615
  * The base implementation of `_.reduce` and `_.reduceRight` without support
2689
- * for callback shorthands or `this` binding, which iterates over `collection`
2616
+ * for callback shorthands and `this` binding, which iterates over `collection`
2690
2617
  * using the provided `eachFunc`.
2691
2618
  *
2692
2619
  * @private
@@ -2753,7 +2680,7 @@
2753
2680
 
2754
2681
  /**
2755
2682
  * The base implementation of `_.some` without support for callback shorthands
2756
- * or `this` binding.
2683
+ * and `this` binding.
2757
2684
  *
2758
2685
  * @private
2759
2686
  * @param {Array|Object|string} collection The collection to iterate over.
@@ -2820,6 +2747,23 @@
2820
2747
  });
2821
2748
  }
2822
2749
 
2750
+ /**
2751
+ * The base implementation of `_.sum` without support for callback shorthands
2752
+ * and `this` binding.
2753
+ *
2754
+ * @private
2755
+ * @param {Array|Object|string} collection The collection to iterate over.
2756
+ * @param {Function} iteratee The function invoked per iteration.
2757
+ * @returns {number} Returns the sum.
2758
+ */
2759
+ function baseSum(collection, iteratee) {
2760
+ var result = 0;
2761
+ baseEach(collection, function(value, index, collection) {
2762
+ result += +iteratee(value, index, collection) || 0;
2763
+ });
2764
+ return result;
2765
+ }
2766
+
2823
2767
  /**
2824
2768
  * The base implementation of `_.uniq` without support for callback shorthands
2825
2769
  * and `this` binding.
@@ -2893,6 +2837,27 @@
2893
2837
  return result;
2894
2838
  }
2895
2839
 
2840
+ /**
2841
+ * The base implementation of `_.dropRightWhile`, `_.dropWhile`, `_.takeRightWhile`,
2842
+ * and `_.takeWhile` without support for callback shorthands and `this` binding.
2843
+ *
2844
+ * @private
2845
+ * @param {Array} array The array to query.
2846
+ * @param {Function} predicate The function invoked per iteration.
2847
+ * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
2848
+ * @param {boolean} [fromRight] Specify iterating from right to left.
2849
+ * @returns {Array} Returns the slice of `array`.
2850
+ */
2851
+ function baseWhile(array, predicate, isDrop, fromRight) {
2852
+ var length = array.length,
2853
+ index = fromRight ? length : -1;
2854
+
2855
+ while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {}
2856
+ return isDrop
2857
+ ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
2858
+ : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
2859
+ }
2860
+
2896
2861
  /**
2897
2862
  * The base implementation of `wrapperValue` which returns the result of
2898
2863
  * performing a sequence of actions on the unwrapped `value`, where each
@@ -2901,7 +2866,7 @@
2901
2866
  * @private
2902
2867
  * @param {*} value The unwrapped value.
2903
2868
  * @param {Array} actions Actions to peform to resolve the unwrapped value.
2904
- * @returns {*} Returns the resolved unwrapped value.
2869
+ * @returns {*} Returns the resolved value.
2905
2870
  */
2906
2871
  function baseWrapperValue(value, actions) {
2907
2872
  var result = value;
@@ -2928,8 +2893,7 @@
2928
2893
  * @private
2929
2894
  * @param {Array} array The sorted array to inspect.
2930
2895
  * @param {*} value The value to evaluate.
2931
- * @param {boolean} [retHighest] Specify returning the highest, instead
2932
- * of the lowest, index at which a value should be inserted into `array`.
2896
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
2933
2897
  * @returns {number} Returns the index at which `value` should be inserted
2934
2898
  * into `array`.
2935
2899
  */
@@ -2962,8 +2926,7 @@
2962
2926
  * @param {Array} array The sorted array to inspect.
2963
2927
  * @param {*} value The value to evaluate.
2964
2928
  * @param {Function} iteratee The function invoked per iteration.
2965
- * @param {boolean} [retHighest] Specify returning the highest, instead
2966
- * of the lowest, index at which a value should be inserted into `array`.
2929
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
2967
2930
  * @returns {number} Returns the index at which `value` should be inserted
2968
2931
  * into `array`.
2969
2932
  */
@@ -3129,6 +3092,9 @@
3129
3092
  * object composed from the results of running each element in the collection
3130
3093
  * through an iteratee.
3131
3094
  *
3095
+ * **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`,
3096
+ * and `_.partition`.
3097
+ *
3132
3098
  * @private
3133
3099
  * @param {Function} setter The function to set keys and values of the accumulator object.
3134
3100
  * @param {Function} [initializer] The function to initialize the accumulator object.
@@ -3160,6 +3126,8 @@
3160
3126
  * Creates a function that assigns properties of source object(s) to a given
3161
3127
  * destination object.
3162
3128
  *
3129
+ * **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`.
3130
+ *
3163
3131
  * @private
3164
3132
  * @param {Function} assigner The function to assign values.
3165
3133
  * @returns {Function} Returns the new assigner function.
@@ -3199,6 +3167,56 @@
3199
3167
  };
3200
3168
  }
3201
3169
 
3170
+ /**
3171
+ * Creates a `baseEach` or `baseEachRight` function.
3172
+ *
3173
+ * @private
3174
+ * @param {Function} eachFunc The function to iterate over a collection.
3175
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3176
+ * @returns {Function} Returns the new base function.
3177
+ */
3178
+ function createBaseEach(eachFunc, fromRight) {
3179
+ return function(collection, iteratee) {
3180
+ var length = collection ? collection.length : 0;
3181
+ if (!isLength(length)) {
3182
+ return eachFunc(collection, iteratee);
3183
+ }
3184
+ var index = fromRight ? length : -1,
3185
+ iterable = toObject(collection);
3186
+
3187
+ while ((fromRight ? index-- : ++index < length)) {
3188
+ if (iteratee(iterable[index], index, iterable) === false) {
3189
+ break;
3190
+ }
3191
+ }
3192
+ return collection;
3193
+ };
3194
+ }
3195
+
3196
+ /**
3197
+ * Creates a base function for `_.forIn` or `_.forInRight`.
3198
+ *
3199
+ * @private
3200
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3201
+ * @returns {Function} Returns the new base function.
3202
+ */
3203
+ function createBaseFor(fromRight) {
3204
+ return function(object, iteratee, keysFunc) {
3205
+ var iterable = toObject(object),
3206
+ props = keysFunc(object),
3207
+ length = props.length,
3208
+ index = fromRight ? length : -1;
3209
+
3210
+ while ((fromRight ? index-- : ++index < length)) {
3211
+ var key = props[index];
3212
+ if (iteratee(iterable[key], key, iterable) === false) {
3213
+ break;
3214
+ }
3215
+ }
3216
+ return object;
3217
+ };
3218
+ }
3219
+
3202
3220
  /**
3203
3221
  * Creates a function that wraps `func` and invokes it with the `this`
3204
3222
  * binding of `thisArg`.
@@ -3229,41 +3247,6 @@
3229
3247
  return new SetCache(values);
3230
3248
  };
3231
3249
 
3232
- /**
3233
- * Creates a function to compose other functions into a single function.
3234
- *
3235
- * @private
3236
- * @param {boolean} [fromRight] Specify iterating from right to left.
3237
- * @returns {Function} Returns the new composer function.
3238
- */
3239
- function createComposer(fromRight) {
3240
- return function() {
3241
- var length = arguments.length,
3242
- index = length,
3243
- fromIndex = fromRight ? (length - 1) : 0;
3244
-
3245
- if (!length) {
3246
- return function() { return arguments[0]; };
3247
- }
3248
- var funcs = Array(length);
3249
- while (index--) {
3250
- funcs[index] = arguments[index];
3251
- if (typeof funcs[index] != 'function') {
3252
- throw new TypeError(FUNC_ERROR_TEXT);
3253
- }
3254
- }
3255
- return function() {
3256
- var index = fromIndex,
3257
- result = funcs[index].apply(this, arguments);
3258
-
3259
- while ((fromRight ? index-- : ++index < length)) {
3260
- result = funcs[index].call(this, result);
3261
- }
3262
- return result;
3263
- };
3264
- };
3265
- }
3266
-
3267
3250
  /**
3268
3251
  * Creates a function that produces compound words out of the words in a
3269
3252
  * given string.
@@ -3306,7 +3289,26 @@
3306
3289
  }
3307
3290
 
3308
3291
  /**
3309
- * Creates a function that gets the extremum value of a collection.
3292
+ * Creates a `_.curry` or `_.curryRight` function.
3293
+ *
3294
+ * @private
3295
+ * @param {boolean} flag The curry bit flag.
3296
+ * @returns {Function} Returns the new curry function.
3297
+ */
3298
+ function createCurry(flag) {
3299
+ function curryFunc(func, arity, guard) {
3300
+ if (guard && isIterateeCall(func, arity, guard)) {
3301
+ arity = null;
3302
+ }
3303
+ var result = createWrapper(func, flag, null, null, null, null, null, arity);
3304
+ result.placeholder = curryFunc.placeholder;
3305
+ return result;
3306
+ }
3307
+ return curryFunc;
3308
+ }
3309
+
3310
+ /**
3311
+ * Creates a `_.max` or `_.min` function.
3310
3312
  *
3311
3313
  * @private
3312
3314
  * @param {Function} arrayFunc The function to get the extremum value from an array.
@@ -3338,6 +3340,204 @@
3338
3340
  };
3339
3341
  }
3340
3342
 
3343
+ /**
3344
+ * Creates a `_.find` or `_.findLast` function.
3345
+ *
3346
+ * @private
3347
+ * @param {Function} eachFunc The function to iterate over a collection.
3348
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3349
+ * @returns {Function} Returns the new find function.
3350
+ */
3351
+ function createFind(eachFunc, fromRight) {
3352
+ return function(collection, predicate, thisArg) {
3353
+ predicate = getCallback(predicate, thisArg, 3);
3354
+ if (isArray(collection)) {
3355
+ var index = baseFindIndex(collection, predicate, fromRight);
3356
+ return index > -1 ? collection[index] : undefined;
3357
+ }
3358
+ return baseFind(collection, predicate, eachFunc);
3359
+ }
3360
+ }
3361
+
3362
+ /**
3363
+ * Creates a `_.findIndex` or `_.findLastIndex` function.
3364
+ *
3365
+ * @private
3366
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3367
+ * @returns {Function} Returns the new find function.
3368
+ */
3369
+ function createFindIndex(fromRight) {
3370
+ return function(array, predicate, thisArg) {
3371
+ if (!(array && array.length)) {
3372
+ return -1;
3373
+ }
3374
+ predicate = getCallback(predicate, thisArg, 3);
3375
+ return baseFindIndex(array, predicate, fromRight);
3376
+ };
3377
+ }
3378
+
3379
+ /**
3380
+ * Creates a `_.findKey` or `_.findLastKey` function.
3381
+ *
3382
+ * @private
3383
+ * @param {Function} objectFunc The function to iterate over an object.
3384
+ * @returns {Function} Returns the new find function.
3385
+ */
3386
+ function createFindKey(objectFunc) {
3387
+ return function(object, predicate, thisArg) {
3388
+ predicate = getCallback(predicate, thisArg, 3);
3389
+ return baseFind(object, predicate, objectFunc, true);
3390
+ };
3391
+ }
3392
+
3393
+ /**
3394
+ * Creates a `_.flow` or `_.flowRight` function.
3395
+ *
3396
+ * @private
3397
+ * @param {boolean} [fromRight] Specify iterating from right to left.
3398
+ * @returns {Function} Returns the new flow function.
3399
+ */
3400
+ function createFlow(fromRight) {
3401
+ return function() {
3402
+ var length = arguments.length;
3403
+ if (!length) {
3404
+ return function() { return arguments[0]; };
3405
+ }
3406
+ var wrapper,
3407
+ index = fromRight ? length : -1,
3408
+ leftIndex = 0,
3409
+ funcs = Array(length);
3410
+
3411
+ while ((fromRight ? index-- : ++index < length)) {
3412
+ var func = funcs[leftIndex++] = arguments[index];
3413
+ if (typeof func != 'function') {
3414
+ throw new TypeError(FUNC_ERROR_TEXT);
3415
+ }
3416
+ var funcName = wrapper ? '' : getFuncName(func);
3417
+ wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper;
3418
+ }
3419
+ index = wrapper ? -1 : length;
3420
+ while (++index < length) {
3421
+ func = funcs[index];
3422
+ funcName = getFuncName(func);
3423
+
3424
+ var data = funcName == 'wrapper' ? getData(func) : null;
3425
+ if (data && isLaziable(data[0])) {
3426
+ wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
3427
+ } else {
3428
+ wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
3429
+ }
3430
+ }
3431
+ return function() {
3432
+ var args = arguments;
3433
+ if (wrapper && args.length == 1 && isArray(args[0])) {
3434
+ return wrapper.plant(args[0]).value();
3435
+ }
3436
+ var index = 0,
3437
+ result = funcs[index].apply(this, args);
3438
+
3439
+ while (++index < length) {
3440
+ result = funcs[index].call(this, result);
3441
+ }
3442
+ return result;
3443
+ };
3444
+ };
3445
+ }
3446
+
3447
+ /**
3448
+ * Creates a function for `_.forEach` or `_.forEachRight`.
3449
+ *
3450
+ * @private
3451
+ * @param {Function} arrayFunc The function to iterate over an array.
3452
+ * @param {Function} eachFunc The function to iterate over a collection.
3453
+ * @returns {Function} Returns the new each function.
3454
+ */
3455
+ function createForEach(arrayFunc, eachFunc) {
3456
+ return function(collection, iteratee, thisArg) {
3457
+ return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
3458
+ ? arrayFunc(collection, iteratee)
3459
+ : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
3460
+ };
3461
+ }
3462
+
3463
+ /**
3464
+ * Creates a function for `_.forIn` or `_.forInRight`.
3465
+ *
3466
+ * @private
3467
+ * @param {Function} objectFunc The function to iterate over an object.
3468
+ * @returns {Function} Returns the new each function.
3469
+ */
3470
+ function createForIn(objectFunc) {
3471
+ return function(object, iteratee, thisArg) {
3472
+ if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
3473
+ iteratee = bindCallback(iteratee, thisArg, 3);
3474
+ }
3475
+ return objectFunc(object, iteratee, keysIn);
3476
+ };
3477
+ }
3478
+
3479
+ /**
3480
+ * Creates a function for `_.forOwn` or `_.forOwnRight`.
3481
+ *
3482
+ * @private
3483
+ * @param {Function} objectFunc The function to iterate over an object.
3484
+ * @returns {Function} Returns the new each function.
3485
+ */
3486
+ function createForOwn(objectFunc) {
3487
+ return function(object, iteratee, thisArg) {
3488
+ if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
3489
+ iteratee = bindCallback(iteratee, thisArg, 3);
3490
+ }
3491
+ return objectFunc(object, iteratee);
3492
+ };
3493
+ }
3494
+
3495
+ /**
3496
+ * Creates a function for `_.padLeft` or `_.padRight`.
3497
+ *
3498
+ * @private
3499
+ * @param {boolean} [fromRight] Specify padding from the right.
3500
+ * @returns {Function} Returns the new pad function.
3501
+ */
3502
+ function createPadDir(fromRight) {
3503
+ return function(string, length, chars) {
3504
+ string = baseToString(string);
3505
+ return string && ((fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string));
3506
+ };
3507
+ }
3508
+
3509
+ /**
3510
+ * Creates a `_.partial` or `_.partialRight` function.
3511
+ *
3512
+ * @private
3513
+ * @param {boolean} flag The partial bit flag.
3514
+ * @returns {Function} Returns the new partial function.
3515
+ */
3516
+ function createPartial(flag) {
3517
+ var partialFunc = restParam(function(func, partials) {
3518
+ var holders = replaceHolders(partials, partialFunc.placeholder);
3519
+ return createWrapper(func, flag, null, partials, holders);
3520
+ });
3521
+ return partialFunc;
3522
+ }
3523
+
3524
+ /**
3525
+ * Creates a function for `_.reduce` or `_.reduceRight`.
3526
+ *
3527
+ * @private
3528
+ * @param {Function} arrayFunc The function to iterate over an array.
3529
+ * @param {Function} eachFunc The function to iterate over a collection.
3530
+ * @returns {Function} Returns the new each function.
3531
+ */
3532
+ function createReduce(arrayFunc, eachFunc) {
3533
+ return function(collection, iteratee, accumulator, thisArg) {
3534
+ var initFromArray = arguments.length < 3;
3535
+ return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
3536
+ ? arrayFunc(collection, iteratee, accumulator, initFromArray)
3537
+ : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
3538
+ };
3539
+ }
3540
+
3341
3541
  /**
3342
3542
  * Creates a function that wraps `func` and invokes it with optional `this`
3343
3543
  * binding of, partial application, and currying.
@@ -3401,7 +3601,12 @@
3401
3601
  if (!isCurryBound) {
3402
3602
  bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
3403
3603
  }
3404
- var result = createHybridWrapper(func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity);
3604
+ var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],
3605
+ result = createHybridWrapper.apply(undefined, newData);
3606
+
3607
+ if (isLaziable(func)) {
3608
+ setData(result, newData);
3609
+ }
3405
3610
  result.placeholder = placeholder;
3406
3611
  return result;
3407
3612
  }
@@ -3423,9 +3628,8 @@
3423
3628
  }
3424
3629
 
3425
3630
  /**
3426
- * Creates the pad required for `string` based on the given padding length.
3427
- * The `chars` string may be truncated if the number of padding characters
3428
- * exceeds the padding length.
3631
+ * Creates the padding required for `string` based on the given `length`.
3632
+ * The `chars` string is truncated if the number of characters exceeds `length`.
3429
3633
  *
3430
3634
  * @private
3431
3635
  * @param {string} string The string to create padding for.
@@ -3433,7 +3637,7 @@
3433
3637
  * @param {string} [chars=' '] The string used as padding.
3434
3638
  * @returns {string} Returns the pad for `string`.
3435
3639
  */
3436
- function createPad(string, length, chars) {
3640
+ function createPadding(string, length, chars) {
3437
3641
  var strLength = string.length;
3438
3642
  length = +length;
3439
3643
 
@@ -3482,6 +3686,22 @@
3482
3686
  return wrapper;
3483
3687
  }
3484
3688
 
3689
+ /**
3690
+ * Creates a `_.sortedIndex` or `_.sortedLastIndex` function.
3691
+ *
3692
+ * @private
3693
+ * @param {boolean} [retHighest] Specify returning the highest qualified index.
3694
+ * @returns {Function} Returns the new index function.
3695
+ */
3696
+ function createSortedIndex(retHighest) {
3697
+ return function(array, value, iteratee, thisArg) {
3698
+ var func = getCallback(iteratee);
3699
+ return (func === baseCallback && iteratee == null)
3700
+ ? binaryIndex(array, value, retHighest)
3701
+ : binaryIndexBy(array, value, func(iteratee, thisArg, 1), retHighest);
3702
+ };
3703
+ }
3704
+
3485
3705
  /**
3486
3706
  * Creates a function that either curries or invokes `func` with optional
3487
3707
  * `this` binding and partially applied arguments.
@@ -3524,10 +3744,10 @@
3524
3744
 
3525
3745
  partials = holders = null;
3526
3746
  }
3527
- var data = !isBindKey && getData(func),
3747
+ var data = isBindKey ? null : getData(func),
3528
3748
  newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
3529
3749
 
3530
- if (data && data !== true) {
3750
+ if (data) {
3531
3751
  mergeData(newData, data);
3532
3752
  bitmask = newData[1];
3533
3753
  arity = newData[9];
@@ -3556,18 +3776,18 @@
3556
3776
  * @param {Array} other The other array to compare.
3557
3777
  * @param {Function} equalFunc The function to determine equivalents of values.
3558
3778
  * @param {Function} [customizer] The function to customize comparing arrays.
3559
- * @param {boolean} [isWhere] Specify performing partial comparisons.
3779
+ * @param {boolean} [isLoose] Specify performing partial comparisons.
3560
3780
  * @param {Array} [stackA] Tracks traversed `value` objects.
3561
3781
  * @param {Array} [stackB] Tracks traversed `other` objects.
3562
3782
  * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
3563
3783
  */
3564
- function equalArrays(array, other, equalFunc, customizer, isWhere, stackA, stackB) {
3784
+ function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
3565
3785
  var index = -1,
3566
3786
  arrLength = array.length,
3567
3787
  othLength = other.length,
3568
3788
  result = true;
3569
3789
 
3570
- if (arrLength != othLength && !(isWhere && othLength > arrLength)) {
3790
+ if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
3571
3791
  return false;
3572
3792
  }
3573
3793
  // Deep compare the contents, ignoring non-numeric properties.
@@ -3577,23 +3797,23 @@
3577
3797
 
3578
3798
  result = undefined;
3579
3799
  if (customizer) {
3580
- result = isWhere
3800
+ result = isLoose
3581
3801
  ? customizer(othValue, arrValue, index)
3582
3802
  : customizer(arrValue, othValue, index);
3583
3803
  }
3584
3804
  if (typeof result == 'undefined') {
3585
3805
  // Recursively compare arrays (susceptible to call stack limits).
3586
- if (isWhere) {
3806
+ if (isLoose) {
3587
3807
  var othIndex = othLength;
3588
3808
  while (othIndex--) {
3589
3809
  othValue = other[othIndex];
3590
- result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB);
3810
+ result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
3591
3811
  if (result) {
3592
3812
  break;
3593
3813
  }
3594
3814
  }
3595
3815
  } else {
3596
- result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isWhere, stackA, stackB);
3816
+ result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
3597
3817
  }
3598
3818
  }
3599
3819
  }
@@ -3649,26 +3869,26 @@
3649
3869
  * @param {Object} other The other object to compare.
3650
3870
  * @param {Function} equalFunc The function to determine equivalents of values.
3651
3871
  * @param {Function} [customizer] The function to customize comparing values.
3652
- * @param {boolean} [isWhere] Specify performing partial comparisons.
3872
+ * @param {boolean} [isLoose] Specify performing partial comparisons.
3653
3873
  * @param {Array} [stackA] Tracks traversed `value` objects.
3654
3874
  * @param {Array} [stackB] Tracks traversed `other` objects.
3655
3875
  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3656
3876
  */
3657
- function equalObjects(object, other, equalFunc, customizer, isWhere, stackA, stackB) {
3877
+ function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
3658
3878
  var objProps = keys(object),
3659
3879
  objLength = objProps.length,
3660
3880
  othProps = keys(other),
3661
3881
  othLength = othProps.length;
3662
3882
 
3663
- if (objLength != othLength && !isWhere) {
3883
+ if (objLength != othLength && !isLoose) {
3664
3884
  return false;
3665
3885
  }
3666
- var hasCtor,
3886
+ var skipCtor = isLoose,
3667
3887
  index = -1;
3668
3888
 
3669
3889
  while (++index < objLength) {
3670
3890
  var key = objProps[index],
3671
- result = hasOwnProperty.call(other, key);
3891
+ result = isLoose ? key in other : hasOwnProperty.call(other, key);
3672
3892
 
3673
3893
  if (result) {
3674
3894
  var objValue = object[key],
@@ -3676,21 +3896,21 @@
3676
3896
 
3677
3897
  result = undefined;
3678
3898
  if (customizer) {
3679
- result = isWhere
3899
+ result = isLoose
3680
3900
  ? customizer(othValue, objValue, key)
3681
3901
  : customizer(objValue, othValue, key);
3682
3902
  }
3683
3903
  if (typeof result == 'undefined') {
3684
3904
  // Recursively compare objects (susceptible to call stack limits).
3685
- result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isWhere, stackA, stackB);
3905
+ result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
3686
3906
  }
3687
3907
  }
3688
3908
  if (!result) {
3689
3909
  return false;
3690
3910
  }
3691
- hasCtor || (hasCtor = key == 'constructor');
3911
+ skipCtor || (skipCtor = key == 'constructor');
3692
3912
  }
3693
- if (!hasCtor) {
3913
+ if (!skipCtor) {
3694
3914
  var objCtor = object.constructor,
3695
3915
  othCtor = other.constructor;
3696
3916
 
@@ -3708,7 +3928,7 @@
3708
3928
  /**
3709
3929
  * Gets the extremum value of `collection` invoking `iteratee` for each value
3710
3930
  * in `collection` to generate the criterion by which the value is ranked.
3711
- * The `iteratee` is invoked with three arguments; (value, index, collection).
3931
+ * The `iteratee` is invoked with three arguments: (value, index, collection).
3712
3932
  *
3713
3933
  * @private
3714
3934
  * @param {Array|Object|string} collection The collection to iterate over.
@@ -3759,6 +3979,37 @@
3759
3979
  return metaMap.get(func);
3760
3980
  };
3761
3981
 
3982
+ /**
3983
+ * Gets the name of `func`.
3984
+ *
3985
+ * @private
3986
+ * @param {Function} func The function to query.
3987
+ * @returns {string} Returns the function name.
3988
+ */
3989
+ var getFuncName = (function() {
3990
+ if (!support.funcNames) {
3991
+ return constant('');
3992
+ }
3993
+ if (constant.name == 'constant') {
3994
+ return baseProperty('name');
3995
+ }
3996
+ return function(func) {
3997
+ var result = func.name,
3998
+ array = realNames[result],
3999
+ length = array ? array.length : 0;
4000
+
4001
+ while (length--) {
4002
+ var data = array[length],
4003
+ otherFunc = data.func;
4004
+
4005
+ if (otherFunc == null || otherFunc == func) {
4006
+ return data.name;
4007
+ }
4008
+ }
4009
+ return result;
4010
+ };
4011
+ }());
4012
+
3762
4013
  /**
3763
4014
  * Gets the appropriate "indexOf" function. If the `_.indexOf` method is
3764
4015
  * customized this function returns the custom method, otherwise it returns
@@ -3880,31 +4131,6 @@
3880
4131
  return result;
3881
4132
  }
3882
4133
 
3883
- /**
3884
- * Checks if `func` is eligible for `this` binding.
3885
- *
3886
- * @private
3887
- * @param {Function} func The function to check.
3888
- * @returns {boolean} Returns `true` if `func` is eligible, else `false`.
3889
- */
3890
- function isBindable(func) {
3891
- var support = lodash.support,
3892
- result = !(support.funcNames ? func.name : support.funcDecomp);
3893
-
3894
- if (!result) {
3895
- var source = fnToString.call(func);
3896
- if (!support.funcNames) {
3897
- result = !reFuncName.test(source);
3898
- }
3899
- if (!result) {
3900
- // Check if `func` references the `this` keyword and store the result.
3901
- result = reThis.test(source) || isNative(func);
3902
- baseSetData(func, result);
3903
- }
3904
- }
3905
- return result;
3906
- }
3907
-
3908
4134
  /**
3909
4135
  * Checks if `value` is a valid array-like index.
3910
4136
  *
@@ -3946,12 +4172,22 @@
3946
4172
  return false;
3947
4173
  }
3948
4174
 
4175
+ /**
4176
+ * Checks if `func` has a lazy counterpart.
4177
+ *
4178
+ * @private
4179
+ * @param {Function} func The function to check.
4180
+ * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
4181
+ */
4182
+ function isLaziable(func) {
4183
+ var funcName = getFuncName(func);
4184
+ return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype;
4185
+ }
4186
+
3949
4187
  /**
3950
4188
  * Checks if `value` is a valid array-like length.
3951
4189
  *
3952
- * **Note:** This function is based on ES `ToLength`. See the
3953
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
3954
- * for more details.
4190
+ * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
3955
4191
  *
3956
4192
  * @private
3957
4193
  * @param {*} value The value to check.
@@ -3991,22 +4227,13 @@
3991
4227
  function mergeData(data, source) {
3992
4228
  var bitmask = data[1],
3993
4229
  srcBitmask = source[1],
3994
- newBitmask = bitmask | srcBitmask;
3995
-
3996
- var arityFlags = ARY_FLAG | REARG_FLAG,
3997
- bindFlags = BIND_FLAG | BIND_KEY_FLAG,
3998
- comboFlags = arityFlags | bindFlags | CURRY_BOUND_FLAG | CURRY_RIGHT_FLAG;
4230
+ newBitmask = bitmask | srcBitmask,
4231
+ isCommon = newBitmask < ARY_FLAG;
3999
4232
 
4000
- var isAry = bitmask & ARY_FLAG && !(srcBitmask & ARY_FLAG),
4001
- isRearg = bitmask & REARG_FLAG && !(srcBitmask & REARG_FLAG),
4002
- argPos = (isRearg ? data : source)[7],
4003
- ary = (isAry ? data : source)[8];
4004
-
4005
- var isCommon = !(bitmask >= REARG_FLAG && srcBitmask > bindFlags) &&
4006
- !(bitmask > bindFlags && srcBitmask >= REARG_FLAG);
4007
-
4008
- var isCombo = (newBitmask >= arityFlags && newBitmask <= comboFlags) &&
4009
- (bitmask < REARG_FLAG || ((isRearg || isAry) && argPos.length <= ary));
4233
+ var isCombo =
4234
+ (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||
4235
+ (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||
4236
+ (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);
4010
4237
 
4011
4238
  // Exit early if metadata can't be merged.
4012
4239
  if (!(isCommon || isCombo)) {
@@ -4347,10 +4574,9 @@
4347
4574
  * Creates an array excluding all values of the provided arrays using
4348
4575
  * `SameValueZero` for equality comparisons.
4349
4576
  *
4350
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
4351
- * e.g. `===`, except that `NaN` matches `NaN`. See the
4352
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4353
- * for more details.
4577
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4578
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
4579
+ * `NaN` matches `NaN`.
4354
4580
  *
4355
4581
  * @static
4356
4582
  * @memberOf _
@@ -4363,19 +4589,11 @@
4363
4589
  * _.difference([1, 2, 3], [4, 2]);
4364
4590
  * // => [1, 3]
4365
4591
  */
4366
- function difference() {
4367
- var args = arguments,
4368
- index = -1,
4369
- length = args.length;
4370
-
4371
- while (++index < length) {
4372
- var value = args[index];
4373
- if (isArray(value) || isArguments(value)) {
4374
- break;
4375
- }
4376
- }
4377
- return baseDifference(value, baseFlatten(args, false, true, ++index));
4378
- }
4592
+ var difference = restParam(function(array, values) {
4593
+ return (isArray(array) || isArguments(array))
4594
+ ? baseDifference(array, baseFlatten(values, false, true))
4595
+ : [];
4596
+ });
4379
4597
 
4380
4598
  /**
4381
4599
  * Creates a slice of `array` with `n` elements dropped from the beginning.
@@ -4451,7 +4669,7 @@
4451
4669
  /**
4452
4670
  * Creates a slice of `array` excluding elements dropped from the end.
4453
4671
  * Elements are dropped until `predicate` returns falsey. The predicate is
4454
- * bound to `thisArg` and invoked with three arguments; (value, index, array).
4672
+ * bound to `thisArg` and invoked with three arguments: (value, index, array).
4455
4673
  *
4456
4674
  * If a property name is provided for `predicate` the created `_.property`
4457
4675
  * style callback returns the property value of the given element.
@@ -4498,19 +4716,15 @@
4498
4716
  * // => ['barney', 'fred', 'pebbles']
4499
4717
  */
4500
4718
  function dropRightWhile(array, predicate, thisArg) {
4501
- var length = array ? array.length : 0;
4502
- if (!length) {
4503
- return [];
4504
- }
4505
- predicate = getCallback(predicate, thisArg, 3);
4506
- while (length-- && predicate(array[length], length, array)) {}
4507
- return baseSlice(array, 0, length + 1);
4719
+ return (array && array.length)
4720
+ ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true)
4721
+ : [];
4508
4722
  }
4509
4723
 
4510
4724
  /**
4511
4725
  * Creates a slice of `array` excluding elements dropped from the beginning.
4512
4726
  * Elements are dropped until `predicate` returns falsey. The predicate is
4513
- * bound to `thisArg` and invoked with three arguments; (value, index, array).
4727
+ * bound to `thisArg` and invoked with three arguments: (value, index, array).
4514
4728
  *
4515
4729
  * If a property name is provided for `predicate` the created `_.property`
4516
4730
  * style callback returns the property value of the given element.
@@ -4557,14 +4771,9 @@
4557
4771
  * // => ['barney', 'fred', 'pebbles']
4558
4772
  */
4559
4773
  function dropWhile(array, predicate, thisArg) {
4560
- var length = array ? array.length : 0;
4561
- if (!length) {
4562
- return [];
4563
- }
4564
- var index = -1;
4565
- predicate = getCallback(predicate, thisArg, 3);
4566
- while (++index < length && predicate(array[index], index, array)) {}
4567
- return baseSlice(array, index);
4774
+ return (array && array.length)
4775
+ ? baseWhile(array, getCallback(predicate, thisArg, 3), true)
4776
+ : [];
4568
4777
  }
4569
4778
 
4570
4779
  /**
@@ -4581,6 +4790,19 @@
4581
4790
  * @param {number} [start=0] The start position.
4582
4791
  * @param {number} [end=array.length] The end position.
4583
4792
  * @returns {Array} Returns `array`.
4793
+ * @example
4794
+ *
4795
+ * var array = [1, 2, 3];
4796
+ *
4797
+ * _.fill(array, 'a');
4798
+ * console.log(array);
4799
+ * // => ['a', 'a', 'a']
4800
+ *
4801
+ * _.fill(Array(3), 2);
4802
+ * // => [2, 2, 2]
4803
+ *
4804
+ * _.fill([4, 6, 8], '*', 1, 2);
4805
+ * // => [4, '*', 8]
4584
4806
  */
4585
4807
  function fill(array, value, start, end) {
4586
4808
  var length = array ? array.length : 0;
@@ -4596,7 +4818,7 @@
4596
4818
 
4597
4819
  /**
4598
4820
  * This method is like `_.find` except that it returns the index of the first
4599
- * element `predicate` returns truthy for, instead of the element itself.
4821
+ * element `predicate` returns truthy for instead of the element itself.
4600
4822
  *
4601
4823
  * If a property name is provided for `predicate` the created `_.property`
4602
4824
  * style callback returns the property value of the given element.
@@ -4642,18 +4864,7 @@
4642
4864
  * _.findIndex(users, 'active');
4643
4865
  * // => 2
4644
4866
  */
4645
- function findIndex(array, predicate, thisArg) {
4646
- var index = -1,
4647
- length = array ? array.length : 0;
4648
-
4649
- predicate = getCallback(predicate, thisArg, 3);
4650
- while (++index < length) {
4651
- if (predicate(array[index], index, array)) {
4652
- return index;
4653
- }
4654
- }
4655
- return -1;
4656
- }
4867
+ var findIndex = createFindIndex();
4657
4868
 
4658
4869
  /**
4659
4870
  * This method is like `_.findIndex` except that it iterates over elements
@@ -4703,16 +4914,7 @@
4703
4914
  * _.findLastIndex(users, 'active');
4704
4915
  * // => 0
4705
4916
  */
4706
- function findLastIndex(array, predicate, thisArg) {
4707
- var length = array ? array.length : 0;
4708
- predicate = getCallback(predicate, thisArg, 3);
4709
- while (length--) {
4710
- if (predicate(array[length], length, array)) {
4711
- return length;
4712
- }
4713
- }
4714
- return -1;
4715
- }
4917
+ var findLastIndex = createFindIndex(true);
4716
4918
 
4717
4919
  /**
4718
4920
  * Gets the first element of `array`.
@@ -4749,18 +4951,18 @@
4749
4951
  * @example
4750
4952
  *
4751
4953
  * _.flatten([1, [2, 3, [4]]]);
4752
- * // => [1, 2, 3, [4]];
4954
+ * // => [1, 2, 3, [4]]
4753
4955
  *
4754
4956
  * // using `isDeep`
4755
4957
  * _.flatten([1, [2, 3, [4]]], true);
4756
- * // => [1, 2, 3, 4];
4958
+ * // => [1, 2, 3, 4]
4757
4959
  */
4758
4960
  function flatten(array, isDeep, guard) {
4759
4961
  var length = array ? array.length : 0;
4760
4962
  if (guard && isIterateeCall(array, isDeep, guard)) {
4761
4963
  isDeep = false;
4762
4964
  }
4763
- return length ? baseFlatten(array, isDeep, false, 0) : [];
4965
+ return length ? baseFlatten(array, isDeep) : [];
4764
4966
  }
4765
4967
 
4766
4968
  /**
@@ -4774,11 +4976,11 @@
4774
4976
  * @example
4775
4977
  *
4776
4978
  * _.flattenDeep([1, [2, 3, [4]]]);
4777
- * // => [1, 2, 3, 4];
4979
+ * // => [1, 2, 3, 4]
4778
4980
  */
4779
4981
  function flattenDeep(array) {
4780
4982
  var length = array ? array.length : 0;
4781
- return length ? baseFlatten(array, true, false, 0) : [];
4983
+ return length ? baseFlatten(array, true) : [];
4782
4984
  }
4783
4985
 
4784
4986
  /**
@@ -4787,10 +4989,9 @@
4787
4989
  * it is used as the offset from the end of `array`. If `array` is sorted
4788
4990
  * providing `true` for `fromIndex` performs a faster binary search.
4789
4991
  *
4790
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
4791
- * e.g. `===`, except that `NaN` matches `NaN`. See the
4792
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4793
- * for more details.
4992
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4993
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
4994
+ * `NaN` matches `NaN`.
4794
4995
  *
4795
4996
  * @static
4796
4997
  * @memberOf _
@@ -4853,10 +5054,9 @@
4853
5054
  * Creates an array of unique values in all provided arrays using `SameValueZero`
4854
5055
  * for equality comparisons.
4855
5056
  *
4856
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
4857
- * e.g. `===`, except that `NaN` matches `NaN`. See the
4858
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4859
- * for more details.
5057
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5058
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
5059
+ * `NaN` matches `NaN`.
4860
5060
  *
4861
5061
  * @static
4862
5062
  * @memberOf _
@@ -4984,10 +5184,10 @@
4984
5184
  * comparisons.
4985
5185
  *
4986
5186
  * **Notes:**
4987
- * - Unlike `_.without`, this method mutates `array`.
4988
- * - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`,
4989
- * except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
4990
- * for more details.
5187
+ * - Unlike `_.without`, this method mutates `array`
5188
+ * - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5189
+ * comparisons are like strict equality comparisons, e.g. `===`, except
5190
+ * that `NaN` matches `NaN`
4991
5191
  *
4992
5192
  * @static
4993
5193
  * @memberOf _
@@ -5050,14 +5250,28 @@
5050
5250
  * console.log(evens);
5051
5251
  * // => [10, 20]
5052
5252
  */
5053
- function pullAt(array) {
5054
- return basePullAt(array || [], baseFlatten(arguments, false, false, 1));
5055
- }
5253
+ var pullAt = restParam(function(array, indexes) {
5254
+ array || (array = []);
5255
+ indexes = baseFlatten(indexes);
5256
+
5257
+ var length = indexes.length,
5258
+ result = baseAt(array, indexes);
5259
+
5260
+ indexes.sort(baseCompareAscending);
5261
+ while (length--) {
5262
+ var index = parseFloat(indexes[length]);
5263
+ if (index != previous && isIndex(index)) {
5264
+ var previous = index;
5265
+ splice.call(array, index, 1);
5266
+ }
5267
+ }
5268
+ return result;
5269
+ });
5056
5270
 
5057
5271
  /**
5058
5272
  * Removes all elements from `array` that `predicate` returns truthy for
5059
5273
  * and returns an array of the removed elements. The predicate is bound to
5060
- * `thisArg` and invoked with three arguments; (value, index, array).
5274
+ * `thisArg` and invoked with three arguments: (value, index, array).
5061
5275
  *
5062
5276
  * If a property name is provided for `predicate` the created `_.property`
5063
5277
  * style callback returns the property value of the given element.
@@ -5161,14 +5375,14 @@
5161
5375
  * to compute their sort ranking. The iteratee is bound to `thisArg` and
5162
5376
  * invoked with one argument; (value).
5163
5377
  *
5164
- * If a property name is provided for `predicate` the created `_.property`
5378
+ * If a property name is provided for `iteratee` the created `_.property`
5165
5379
  * style callback returns the property value of the given element.
5166
5380
  *
5167
5381
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
5168
5382
  * style callback returns `true` for elements that have a matching property
5169
5383
  * value, else `false`.
5170
5384
  *
5171
- * If an object is provided for `predicate` the created `_.matches` style
5385
+ * If an object is provided for `iteratee` the created `_.matches` style
5172
5386
  * callback returns `true` for elements that have the properties of the given
5173
5387
  * object, else `false`.
5174
5388
  *
@@ -5202,12 +5416,7 @@
5202
5416
  * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
5203
5417
  * // => 1
5204
5418
  */
5205
- function sortedIndex(array, value, iteratee, thisArg) {
5206
- var func = getCallback(iteratee);
5207
- return (func === baseCallback && iteratee == null)
5208
- ? binaryIndex(array, value)
5209
- : binaryIndexBy(array, value, func(iteratee, thisArg, 1));
5210
- }
5419
+ var sortedIndex = createSortedIndex();
5211
5420
 
5212
5421
  /**
5213
5422
  * This method is like `_.sortedIndex` except that it returns the highest
@@ -5229,12 +5438,7 @@
5229
5438
  * _.sortedLastIndex([4, 4, 5, 5], 5);
5230
5439
  * // => 4
5231
5440
  */
5232
- function sortedLastIndex(array, value, iteratee, thisArg) {
5233
- var func = getCallback(iteratee);
5234
- return (func === baseCallback && iteratee == null)
5235
- ? binaryIndex(array, value, true)
5236
- : binaryIndexBy(array, value, func(iteratee, thisArg, 1), true);
5237
- }
5441
+ var sortedLastIndex = createSortedIndex(true);
5238
5442
 
5239
5443
  /**
5240
5444
  * Creates a slice of `array` with `n` elements taken from the beginning.
@@ -5310,7 +5514,7 @@
5310
5514
  /**
5311
5515
  * Creates a slice of `array` with elements taken from the end. Elements are
5312
5516
  * taken until `predicate` returns falsey. The predicate is bound to `thisArg`
5313
- * and invoked with three arguments; (value, index, array).
5517
+ * and invoked with three arguments: (value, index, array).
5314
5518
  *
5315
5519
  * If a property name is provided for `predicate` the created `_.property`
5316
5520
  * style callback returns the property value of the given element.
@@ -5357,19 +5561,15 @@
5357
5561
  * // => []
5358
5562
  */
5359
5563
  function takeRightWhile(array, predicate, thisArg) {
5360
- var length = array ? array.length : 0;
5361
- if (!length) {
5362
- return [];
5363
- }
5364
- predicate = getCallback(predicate, thisArg, 3);
5365
- while (length-- && predicate(array[length], length, array)) {}
5366
- return baseSlice(array, length + 1);
5564
+ return (array && array.length)
5565
+ ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true)
5566
+ : [];
5367
5567
  }
5368
5568
 
5369
5569
  /**
5370
5570
  * Creates a slice of `array` with elements taken from the beginning. Elements
5371
5571
  * are taken until `predicate` returns falsey. The predicate is bound to
5372
- * `thisArg` and invoked with three arguments; (value, index, array).
5572
+ * `thisArg` and invoked with three arguments: (value, index, array).
5373
5573
  *
5374
5574
  * If a property name is provided for `predicate` the created `_.property`
5375
5575
  * style callback returns the property value of the given element.
@@ -5416,24 +5616,18 @@
5416
5616
  * // => []
5417
5617
  */
5418
5618
  function takeWhile(array, predicate, thisArg) {
5419
- var length = array ? array.length : 0;
5420
- if (!length) {
5421
- return [];
5422
- }
5423
- var index = -1;
5424
- predicate = getCallback(predicate, thisArg, 3);
5425
- while (++index < length && predicate(array[index], index, array)) {}
5426
- return baseSlice(array, 0, index);
5619
+ return (array && array.length)
5620
+ ? baseWhile(array, getCallback(predicate, thisArg, 3))
5621
+ : [];
5427
5622
  }
5428
5623
 
5429
5624
  /**
5430
5625
  * Creates an array of unique values, in order, of the provided arrays using
5431
5626
  * `SameValueZero` for equality comparisons.
5432
5627
  *
5433
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
5434
- * e.g. `===`, except that `NaN` matches `NaN`. See the
5435
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5436
- * for more details.
5628
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5629
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
5630
+ * `NaN` matches `NaN`.
5437
5631
  *
5438
5632
  * @static
5439
5633
  * @memberOf _
@@ -5445,9 +5639,9 @@
5445
5639
  * _.union([1, 2], [4, 2], [2, 1]);
5446
5640
  * // => [1, 2, 4]
5447
5641
  */
5448
- function union() {
5449
- return baseUniq(baseFlatten(arguments, false, true, 0));
5450
- }
5642
+ var union = restParam(function(arrays) {
5643
+ return baseUniq(baseFlatten(arrays, false, true));
5644
+ });
5451
5645
 
5452
5646
  /**
5453
5647
  * Creates a duplicate-value-free version of an array using `SameValueZero`
@@ -5455,23 +5649,22 @@
5455
5649
  * search algorithm for sorted arrays. If an iteratee function is provided it
5456
5650
  * is invoked for each value in the array to generate the criterion by which
5457
5651
  * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
5458
- * with three arguments; (value, index, array).
5652
+ * with three arguments: (value, index, array).
5459
5653
  *
5460
- * If a property name is provided for `predicate` the created `_.property`
5654
+ * If a property name is provided for `iteratee` the created `_.property`
5461
5655
  * style callback returns the property value of the given element.
5462
5656
  *
5463
5657
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
5464
5658
  * style callback returns `true` for elements that have a matching property
5465
5659
  * value, else `false`.
5466
5660
  *
5467
- * If an object is provided for `predicate` the created `_.matches` style
5661
+ * If an object is provided for `iteratee` the created `_.matches` style
5468
5662
  * callback returns `true` for elements that have the properties of the given
5469
5663
  * object, else `false`.
5470
5664
  *
5471
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
5472
- * e.g. `===`, except that `NaN` matches `NaN`. See the
5473
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5474
- * for more details.
5665
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5666
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
5667
+ * `NaN` matches `NaN`.
5475
5668
  *
5476
5669
  * @static
5477
5670
  * @memberOf _
@@ -5553,10 +5746,9 @@
5553
5746
  * Creates an array excluding all provided values using `SameValueZero` for
5554
5747
  * equality comparisons.
5555
5748
  *
5556
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
5557
- * e.g. `===`, except that `NaN` matches `NaN`. See the
5558
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5559
- * for more details.
5749
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
5750
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
5751
+ * `NaN` matches `NaN`.
5560
5752
  *
5561
5753
  * @static
5562
5754
  * @memberOf _
@@ -5569,14 +5761,15 @@
5569
5761
  * _.without([1, 2, 1, 3], 1, 2);
5570
5762
  * // => [3]
5571
5763
  */
5572
- function without(array) {
5573
- return baseDifference(array, baseSlice(arguments, 1));
5574
- }
5764
+ var without = restParam(function(array, values) {
5765
+ return (isArray(array) || isArguments(array))
5766
+ ? baseDifference(array, values)
5767
+ : [];
5768
+ });
5575
5769
 
5576
5770
  /**
5577
- * Creates an array that is the symmetric difference of the provided arrays.
5578
- * See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for
5579
- * more details.
5771
+ * Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
5772
+ * of the provided arrays.
5580
5773
  *
5581
5774
  * @static
5582
5775
  * @memberOf _
@@ -5618,20 +5811,13 @@
5618
5811
  * _.zip(['fred', 'barney'], [30, 40], [true, false]);
5619
5812
  * // => [['fred', 30, true], ['barney', 40, false]]
5620
5813
  */
5621
- function zip() {
5622
- var length = arguments.length,
5623
- array = Array(length);
5624
-
5625
- while (length--) {
5626
- array[length] = arguments[length];
5627
- }
5628
- return unzip(array);
5629
- }
5814
+ var zip = restParam(unzip);
5630
5815
 
5631
5816
  /**
5632
- * Creates an object composed from arrays of property names and values. Provide
5633
- * either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]`
5634
- * or two arrays, one of property names and one of corresponding values.
5817
+ * The inverse of `_.pairs`; this method returns an object composed from arrays
5818
+ * of property names and values. Provide either a single two dimensional array,
5819
+ * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names
5820
+ * and one of corresponding values.
5635
5821
  *
5636
5822
  * @static
5637
5823
  * @memberOf _
@@ -5642,6 +5828,9 @@
5642
5828
  * @returns {Object} Returns the new object.
5643
5829
  * @example
5644
5830
  *
5831
+ * _.zipObject([['fred', 30], ['barney', 40]]);
5832
+ * // => { 'fred': 30, 'barney': 40 }
5833
+ *
5645
5834
  * _.zipObject(['fred', 'barney'], [30, 40]);
5646
5835
  * // => { 'fred': 30, 'barney': 40 }
5647
5836
  */
@@ -5738,13 +5927,14 @@
5738
5927
  * @returns {*} Returns the result of `interceptor`.
5739
5928
  * @example
5740
5929
  *
5741
- * _([1, 2, 3])
5742
- * .last()
5930
+ * _(' abc ')
5931
+ * .chain()
5932
+ * .trim()
5743
5933
  * .thru(function(value) {
5744
5934
  * return [value];
5745
5935
  * })
5746
5936
  * .value();
5747
- * // => [3]
5937
+ * // => ['abc']
5748
5938
  */
5749
5939
  function thru(value, interceptor, thisArg) {
5750
5940
  return interceptor.call(thisArg, value);
@@ -5934,32 +6124,32 @@
5934
6124
  * _.at(['a', 'b', 'c'], [0, 2]);
5935
6125
  * // => ['a', 'c']
5936
6126
  *
5937
- * _.at(['fred', 'barney', 'pebbles'], 0, 2);
5938
- * // => ['fred', 'pebbles']
6127
+ * _.at(['barney', 'fred', 'pebbles'], 0, 2);
6128
+ * // => ['barney', 'pebbles']
5939
6129
  */
5940
- function at(collection) {
6130
+ var at = restParam(function(collection, props) {
5941
6131
  var length = collection ? collection.length : 0;
5942
6132
  if (isLength(length)) {
5943
6133
  collection = toIterable(collection);
5944
6134
  }
5945
- return baseAt(collection, baseFlatten(arguments, false, false, 1));
5946
- }
6135
+ return baseAt(collection, baseFlatten(props));
6136
+ });
5947
6137
 
5948
6138
  /**
5949
6139
  * Creates an object composed of keys generated from the results of running
5950
6140
  * each element of `collection` through `iteratee`. The corresponding value
5951
6141
  * of each key is the number of times the key was returned by `iteratee`.
5952
- * The `iteratee` is bound to `thisArg` and invoked with three arguments;
6142
+ * The `iteratee` is bound to `thisArg` and invoked with three arguments:
5953
6143
  * (value, index|key, collection).
5954
6144
  *
5955
- * If a property name is provided for `predicate` the created `_.property`
6145
+ * If a property name is provided for `iteratee` the created `_.property`
5956
6146
  * style callback returns the property value of the given element.
5957
6147
  *
5958
6148
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
5959
6149
  * style callback returns `true` for elements that have a matching property
5960
6150
  * value, else `false`.
5961
6151
  *
5962
- * If an object is provided for `predicate` the created `_.matches` style
6152
+ * If an object is provided for `iteratee` the created `_.matches` style
5963
6153
  * callback returns `true` for elements that have the properties of the given
5964
6154
  * object, else `false`.
5965
6155
  *
@@ -5992,7 +6182,7 @@
5992
6182
 
5993
6183
  /**
5994
6184
  * Checks if `predicate` returns truthy for **all** elements of `collection`.
5995
- * The predicate is bound to `thisArg` and invoked with three arguments;
6185
+ * The predicate is bound to `thisArg` and invoked with three arguments:
5996
6186
  * (value, index|key, collection).
5997
6187
  *
5998
6188
  * If a property name is provided for `predicate` the created `_.property`
@@ -6040,6 +6230,9 @@
6040
6230
  */
6041
6231
  function every(collection, predicate, thisArg) {
6042
6232
  var func = isArray(collection) ? arrayEvery : baseEvery;
6233
+ if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
6234
+ predicate = null;
6235
+ }
6043
6236
  if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
6044
6237
  predicate = getCallback(predicate, thisArg, 3);
6045
6238
  }
@@ -6049,7 +6242,7 @@
6049
6242
  /**
6050
6243
  * Iterates over elements of `collection`, returning an array of all elements
6051
6244
  * `predicate` returns truthy for. The predicate is bound to `thisArg` and
6052
- * invoked with three arguments; (value, index|key, collection).
6245
+ * invoked with three arguments: (value, index|key, collection).
6053
6246
  *
6054
6247
  * If a property name is provided for `predicate` the created `_.property`
6055
6248
  * style callback returns the property value of the given element.
@@ -6104,7 +6297,7 @@
6104
6297
  /**
6105
6298
  * Iterates over elements of `collection`, returning the first element
6106
6299
  * `predicate` returns truthy for. The predicate is bound to `thisArg` and
6107
- * invoked with three arguments; (value, index|key, collection).
6300
+ * invoked with three arguments: (value, index|key, collection).
6108
6301
  *
6109
6302
  * If a property name is provided for `predicate` the created `_.property`
6110
6303
  * style callback returns the property value of the given element.
@@ -6151,14 +6344,7 @@
6151
6344
  * _.result(_.find(users, 'active'), 'user');
6152
6345
  * // => 'barney'
6153
6346
  */
6154
- function find(collection, predicate, thisArg) {
6155
- if (isArray(collection)) {
6156
- var index = findIndex(collection, predicate, thisArg);
6157
- return index > -1 ? collection[index] : undefined;
6158
- }
6159
- predicate = getCallback(predicate, thisArg, 3);
6160
- return baseFind(collection, predicate, baseEach);
6161
- }
6347
+ var find = createFind(baseEach);
6162
6348
 
6163
6349
  /**
6164
6350
  * This method is like `_.find` except that it iterates over elements of
@@ -6179,10 +6365,7 @@
6179
6365
  * });
6180
6366
  * // => 3
6181
6367
  */
6182
- function findLast(collection, predicate, thisArg) {
6183
- predicate = getCallback(predicate, thisArg, 3);
6184
- return baseFind(collection, predicate, baseEachRight);
6185
- }
6368
+ var findLast = createFind(baseEachRight, true);
6186
6369
 
6187
6370
  /**
6188
6371
  * Performs a deep comparison between each element in `collection` and the
@@ -6219,7 +6402,7 @@
6219
6402
 
6220
6403
  /**
6221
6404
  * Iterates over elements of `collection` invoking `iteratee` for each element.
6222
- * The `iteratee` is bound to `thisArg` and invoked with three arguments;
6405
+ * The `iteratee` is bound to `thisArg` and invoked with three arguments:
6223
6406
  * (value, index|key, collection). Iterator functions may exit iteration early
6224
6407
  * by explicitly returning `false`.
6225
6408
  *
@@ -6247,11 +6430,7 @@
6247
6430
  * });
6248
6431
  * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
6249
6432
  */
6250
- function forEach(collection, iteratee, thisArg) {
6251
- return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
6252
- ? arrayEach(collection, iteratee)
6253
- : baseEach(collection, bindCallback(iteratee, thisArg, 3));
6254
- }
6433
+ var forEach = createForEach(arrayEach, baseEach);
6255
6434
 
6256
6435
  /**
6257
6436
  * This method is like `_.forEach` except that it iterates over elements of
@@ -6269,30 +6448,26 @@
6269
6448
  *
6270
6449
  * _([1, 2]).forEachRight(function(n) {
6271
6450
  * console.log(n);
6272
- * }).join(',');
6451
+ * }).value();
6273
6452
  * // => logs each value from right to left and returns the array
6274
6453
  */
6275
- function forEachRight(collection, iteratee, thisArg) {
6276
- return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
6277
- ? arrayEachRight(collection, iteratee)
6278
- : baseEachRight(collection, bindCallback(iteratee, thisArg, 3));
6279
- }
6454
+ var forEachRight = createForEach(arrayEachRight, baseEachRight);
6280
6455
 
6281
6456
  /**
6282
6457
  * Creates an object composed of keys generated from the results of running
6283
6458
  * each element of `collection` through `iteratee`. The corresponding value
6284
6459
  * of each key is an array of the elements responsible for generating the key.
6285
- * The `iteratee` is bound to `thisArg` and invoked with three arguments;
6460
+ * The `iteratee` is bound to `thisArg` and invoked with three arguments:
6286
6461
  * (value, index|key, collection).
6287
6462
  *
6288
- * If a property name is provided for `predicate` the created `_.property`
6463
+ * If a property name is provided for `iteratee` the created `_.property`
6289
6464
  * style callback returns the property value of the given element.
6290
6465
  *
6291
6466
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
6292
6467
  * style callback returns `true` for elements that have a matching property
6293
6468
  * value, else `false`.
6294
6469
  *
6295
- * If an object is provided for `predicate` the created `_.matches` style
6470
+ * If an object is provided for `iteratee` the created `_.matches` style
6296
6471
  * callback returns `true` for elements that have the properties of the given
6297
6472
  * object, else `false`.
6298
6473
  *
@@ -6333,10 +6508,9 @@
6333
6508
  * comparisons. If `fromIndex` is negative, it is used as the offset from
6334
6509
  * the end of `collection`.
6335
6510
  *
6336
- * **Note:** `SameValueZero` comparisons are like strict equality comparisons,
6337
- * e.g. `===`, except that `NaN` matches `NaN`. See the
6338
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
6339
- * for more details.
6511
+ * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
6512
+ * comparisons are like strict equality comparisons, e.g. `===`, except that
6513
+ * `NaN` matches `NaN`.
6340
6514
  *
6341
6515
  * @static
6342
6516
  * @memberOf _
@@ -6345,6 +6519,7 @@
6345
6519
  * @param {Array|Object|string} collection The collection to search.
6346
6520
  * @param {*} target The value to search for.
6347
6521
  * @param {number} [fromIndex=0] The index to search from.
6522
+ * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
6348
6523
  * @returns {boolean} Returns `true` if a matching element is found, else `false`.
6349
6524
  * @example
6350
6525
  *
@@ -6360,7 +6535,7 @@
6360
6535
  * _.includes('pebbles', 'eb');
6361
6536
  * // => true
6362
6537
  */
6363
- function includes(collection, target, fromIndex) {
6538
+ function includes(collection, target, fromIndex, guard) {
6364
6539
  var length = collection ? collection.length : 0;
6365
6540
  if (!isLength(length)) {
6366
6541
  collection = values(collection);
@@ -6369,10 +6544,10 @@
6369
6544
  if (!length) {
6370
6545
  return false;
6371
6546
  }
6372
- if (typeof fromIndex == 'number') {
6373
- fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
6374
- } else {
6547
+ if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
6375
6548
  fromIndex = 0;
6549
+ } else {
6550
+ fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
6376
6551
  }
6377
6552
  return (typeof collection == 'string' || !isArray(collection) && isString(collection))
6378
6553
  ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
@@ -6383,17 +6558,17 @@
6383
6558
  * Creates an object composed of keys generated from the results of running
6384
6559
  * each element of `collection` through `iteratee`. The corresponding value
6385
6560
  * of each key is the last element responsible for generating the key. The
6386
- * iteratee function is bound to `thisArg` and invoked with three arguments;
6561
+ * iteratee function is bound to `thisArg` and invoked with three arguments:
6387
6562
  * (value, index|key, collection).
6388
6563
  *
6389
- * If a property name is provided for `predicate` the created `_.property`
6564
+ * If a property name is provided for `iteratee` the created `_.property`
6390
6565
  * style callback returns the property value of the given element.
6391
6566
  *
6392
6567
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
6393
6568
  * style callback returns `true` for elements that have a matching property
6394
6569
  * value, else `false`.
6395
6570
  *
6396
- * If an object is provided for `predicate` the created `_.matches` style
6571
+ * If an object is provided for `iteratee` the created `_.matches` style
6397
6572
  * callback returns `true` for elements that have the properties of the given
6398
6573
  * object, else `false`.
6399
6574
  *
@@ -6451,23 +6626,32 @@
6451
6626
  * _.invoke([123, 456], String.prototype.split, '');
6452
6627
  * // => [['1', '2', '3'], ['4', '5', '6']]
6453
6628
  */
6454
- function invoke(collection, methodName) {
6455
- return baseInvoke(collection, methodName, baseSlice(arguments, 2));
6456
- }
6629
+ var invoke = restParam(function(collection, methodName, args) {
6630
+ var index = -1,
6631
+ isFunc = typeof methodName == 'function',
6632
+ length = collection ? collection.length : 0,
6633
+ result = isLength(length) ? Array(length) : [];
6634
+
6635
+ baseEach(collection, function(value) {
6636
+ var func = isFunc ? methodName : (value != null && value[methodName]);
6637
+ result[++index] = func ? func.apply(value, args) : undefined;
6638
+ });
6639
+ return result;
6640
+ });
6457
6641
 
6458
6642
  /**
6459
6643
  * Creates an array of values by running each element in `collection` through
6460
6644
  * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
6461
- * arguments; (value, index|key, collection).
6645
+ * arguments: (value, index|key, collection).
6462
6646
  *
6463
- * If a property name is provided for `predicate` the created `_.property`
6647
+ * If a property name is provided for `iteratee` the created `_.property`
6464
6648
  * style callback returns the property value of the given element.
6465
6649
  *
6466
6650
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
6467
6651
  * style callback returns `true` for elements that have a matching property
6468
6652
  * value, else `false`.
6469
6653
  *
6470
- * If an object is provided for `predicate` the created `_.matches` style
6654
+ * If an object is provided for `iteratee` the created `_.matches` style
6471
6655
  * callback returns `true` for elements that have the properties of the given
6472
6656
  * object, else `false`.
6473
6657
  *
@@ -6476,9 +6660,9 @@
6476
6660
  *
6477
6661
  * The guarded methods are:
6478
6662
  * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
6479
- * `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
6480
- * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
6481
- * `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
6663
+ * `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
6664
+ * `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
6665
+ * `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
6482
6666
  *
6483
6667
  * @static
6484
6668
  * @memberOf _
@@ -6521,7 +6705,7 @@
6521
6705
  * Creates an array of elements split into two groups, the first of which
6522
6706
  * contains elements `predicate` returns truthy for, while the second of which
6523
6707
  * contains elements `predicate` returns falsey for. The predicate is bound
6524
- * to `thisArg` and invoked with three arguments; (value, index|key, collection).
6708
+ * to `thisArg` and invoked with three arguments: (value, index|key, collection).
6525
6709
  *
6526
6710
  * If a property name is provided for `predicate` the created `_.property`
6527
6711
  * style callback returns the property value of the given element.
@@ -6612,14 +6796,14 @@
6612
6796
  * each element in `collection` through `iteratee`, where each successive
6613
6797
  * invocation is supplied the return value of the previous. If `accumulator`
6614
6798
  * is not provided the first element of `collection` is used as the initial
6615
- * value. The `iteratee` is bound to `thisArg`and invoked with four arguments;
6799
+ * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
6616
6800
  * (accumulator, value, index|key, collection).
6617
6801
  *
6618
6802
  * Many lodash methods are guarded to work as interatees for methods like
6619
6803
  * `_.reduce`, `_.reduceRight`, and `_.transform`.
6620
6804
  *
6621
6805
  * The guarded methods are:
6622
- * `assign`, `defaults`, `merge`, and `sortAllBy`
6806
+ * `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`
6623
6807
  *
6624
6808
  * @static
6625
6809
  * @memberOf _
@@ -6643,10 +6827,7 @@
6643
6827
  * }, {});
6644
6828
  * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
6645
6829
  */
6646
- function reduce(collection, iteratee, accumulator, thisArg) {
6647
- var func = isArray(collection) ? arrayReduce : baseReduce;
6648
- return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach);
6649
- }
6830
+ var reduce = createReduce(arrayReduce, baseEach);
6650
6831
 
6651
6832
  /**
6652
6833
  * This method is like `_.reduce` except that it iterates over elements of
@@ -6670,10 +6851,7 @@
6670
6851
  * }, []);
6671
6852
  * // => [4, 5, 2, 3, 0, 1]
6672
6853
  */
6673
- function reduceRight(collection, iteratee, accumulator, thisArg) {
6674
- var func = isArray(collection) ? arrayReduceRight : baseReduce;
6675
- return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
6676
- }
6854
+ var reduceRight = createReduce(arrayReduceRight, baseEachRight);
6677
6855
 
6678
6856
  /**
6679
6857
  * The opposite of `_.filter`; this method returns the elements of `collection`
@@ -6760,9 +6938,8 @@
6760
6938
  }
6761
6939
 
6762
6940
  /**
6763
- * Creates an array of shuffled values, using a version of the Fisher-Yates
6764
- * shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle)
6765
- * for more details.
6941
+ * Creates an array of shuffled values, using a version of the
6942
+ * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
6766
6943
  *
6767
6944
  * @static
6768
6945
  * @memberOf _
@@ -6820,7 +6997,7 @@
6820
6997
  * Checks if `predicate` returns truthy for **any** element of `collection`.
6821
6998
  * The function returns as soon as it finds a passing value and does not iterate
6822
6999
  * over the entire collection. The predicate is bound to `thisArg` and invoked
6823
- * with three arguments; (value, index|key, collection).
7000
+ * with three arguments: (value, index|key, collection).
6824
7001
  *
6825
7002
  * If a property name is provided for `predicate` the created `_.property`
6826
7003
  * style callback returns the property value of the given element.
@@ -6867,6 +7044,9 @@
6867
7044
  */
6868
7045
  function some(collection, predicate, thisArg) {
6869
7046
  var func = isArray(collection) ? arraySome : baseSome;
7047
+ if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
7048
+ predicate = null;
7049
+ }
6870
7050
  if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
6871
7051
  predicate = getCallback(predicate, thisArg, 3);
6872
7052
  }
@@ -6877,17 +7057,17 @@
6877
7057
  * Creates an array of elements, sorted in ascending order by the results of
6878
7058
  * running each element in a collection through `iteratee`. This method performs
6879
7059
  * a stable sort, that is, it preserves the original sort order of equal elements.
6880
- * The `iteratee` is bound to `thisArg` and invoked with three arguments;
7060
+ * The `iteratee` is bound to `thisArg` and invoked with three arguments:
6881
7061
  * (value, index|key, collection).
6882
7062
  *
6883
- * If a property name is provided for `predicate` the created `_.property`
7063
+ * If a property name is provided for `iteratee` the created `_.property`
6884
7064
  * style callback returns the property value of the given element.
6885
7065
  *
6886
7066
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
6887
7067
  * style callback returns `true` for elements that have a matching property
6888
7068
  * value, else `false`.
6889
7069
  *
6890
- * If an object is provided for `predicate` the created `_.matches` style
7070
+ * If an object is provided for `iteratee` the created `_.matches` style
6891
7071
  * callback returns `true` for elements that have the properties of the given
6892
7072
  * object, else `false`.
6893
7073
  *
@@ -6963,17 +7143,24 @@
6963
7143
  * _.map(_.sortByAll(users, ['user', 'age']), _.values);
6964
7144
  * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
6965
7145
  */
6966
- function sortByAll(collection) {
7146
+ function sortByAll() {
7147
+ var args = arguments,
7148
+ collection = args[0],
7149
+ guard = args[3],
7150
+ index = 0,
7151
+ length = args.length - 1;
7152
+
6967
7153
  if (collection == null) {
6968
7154
  return [];
6969
7155
  }
6970
- var args = arguments,
6971
- guard = args[3];
6972
-
7156
+ var props = Array(length);
7157
+ while (index < length) {
7158
+ props[index] = args[++index];
7159
+ }
6973
7160
  if (guard && isIterateeCall(args[1], args[2], guard)) {
6974
- args = [collection, args[1]];
7161
+ props = args[1];
6975
7162
  }
6976
- return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []);
7163
+ return baseSortByOrder(collection, baseFlatten(props), []);
6977
7164
  }
6978
7165
 
6979
7166
  /**
@@ -7192,7 +7379,7 @@
7192
7379
  * @category Function
7193
7380
  * @param {Function} func The function to bind.
7194
7381
  * @param {*} thisArg The `this` binding of `func`.
7195
- * @param {...*} [args] The arguments to be partially applied.
7382
+ * @param {...*} [partials] The arguments to be partially applied.
7196
7383
  * @returns {Function} Returns the new bound function.
7197
7384
  * @example
7198
7385
  *
@@ -7211,16 +7398,14 @@
7211
7398
  * bound('hi');
7212
7399
  * // => 'hi fred!'
7213
7400
  */
7214
- function bind(func, thisArg) {
7401
+ var bind = restParam(function(func, thisArg, partials) {
7215
7402
  var bitmask = BIND_FLAG;
7216
- if (arguments.length > 2) {
7217
- var partials = baseSlice(arguments, 2),
7218
- holders = replaceHolders(partials, bind.placeholder);
7219
-
7403
+ if (partials.length) {
7404
+ var holders = replaceHolders(partials, bind.placeholder);
7220
7405
  bitmask |= PARTIAL_FLAG;
7221
7406
  }
7222
7407
  return createWrapper(func, bitmask, thisArg, partials, holders);
7223
- }
7408
+ });
7224
7409
 
7225
7410
  /**
7226
7411
  * Binds methods of an object to the object itself, overwriting the existing
@@ -7250,13 +7435,18 @@
7250
7435
  * jQuery('#docs').on('click', view.onClick);
7251
7436
  * // => logs 'clicked docs' when the element is clicked
7252
7437
  */
7253
- function bindAll(object) {
7254
- return baseBindAll(object,
7255
- arguments.length > 1
7256
- ? baseFlatten(arguments, false, false, 1)
7257
- : functions(object)
7258
- );
7259
- }
7438
+ var bindAll = restParam(function(object, methodNames) {
7439
+ methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);
7440
+
7441
+ var index = -1,
7442
+ length = methodNames.length;
7443
+
7444
+ while (++index < length) {
7445
+ var key = methodNames[index];
7446
+ object[key] = createWrapper(object[key], BIND_FLAG, object);
7447
+ }
7448
+ return object;
7449
+ });
7260
7450
 
7261
7451
  /**
7262
7452
  * Creates a function that invokes the method at `object[key]` and prepends
@@ -7275,7 +7465,7 @@
7275
7465
  * @category Function
7276
7466
  * @param {Object} object The object the method belongs to.
7277
7467
  * @param {string} key The key of the method.
7278
- * @param {...*} [args] The arguments to be partially applied.
7468
+ * @param {...*} [partials] The arguments to be partially applied.
7279
7469
  * @returns {Function} Returns the new bound function.
7280
7470
  * @example
7281
7471
  *
@@ -7302,16 +7492,14 @@
7302
7492
  * bound('hi');
7303
7493
  * // => 'hiya fred!'
7304
7494
  */
7305
- function bindKey(object, key) {
7495
+ var bindKey = restParam(function(object, key, partials) {
7306
7496
  var bitmask = BIND_FLAG | BIND_KEY_FLAG;
7307
- if (arguments.length > 2) {
7308
- var partials = baseSlice(arguments, 2),
7309
- holders = replaceHolders(partials, bindKey.placeholder);
7310
-
7497
+ if (partials.length) {
7498
+ var holders = replaceHolders(partials, bindKey.placeholder);
7311
7499
  bitmask |= PARTIAL_FLAG;
7312
7500
  }
7313
7501
  return createWrapper(key, bitmask, object, partials, holders);
7314
- }
7502
+ });
7315
7503
 
7316
7504
  /**
7317
7505
  * Creates a function that accepts one or more arguments of `func` that when
@@ -7353,14 +7541,7 @@
7353
7541
  * curried(1)(_, 3)(2);
7354
7542
  * // => [1, 2, 3]
7355
7543
  */
7356
- function curry(func, arity, guard) {
7357
- if (guard && isIterateeCall(func, arity, guard)) {
7358
- arity = null;
7359
- }
7360
- var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity);
7361
- result.placeholder = curry.placeholder;
7362
- return result;
7363
- }
7544
+ var curry = createCurry(CURRY_FLAG);
7364
7545
 
7365
7546
  /**
7366
7547
  * This method is like `_.curry` except that arguments are applied to `func`
@@ -7399,14 +7580,7 @@
7399
7580
  * curried(3)(1, _)(2);
7400
7581
  * // => [1, 2, 3]
7401
7582
  */
7402
- function curryRight(func, arity, guard) {
7403
- if (guard && isIterateeCall(func, arity, guard)) {
7404
- arity = null;
7405
- }
7406
- var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity);
7407
- result.placeholder = curryRight.placeholder;
7408
- return result;
7409
- }
7583
+ var curryRight = createCurry(CURRY_RIGHT_FLAG);
7410
7584
 
7411
7585
  /**
7412
7586
  * Creates a function that delays invoking `func` until after `wait` milliseconds
@@ -7601,9 +7775,9 @@
7601
7775
  * }, 'deferred');
7602
7776
  * // logs 'deferred' after one or more milliseconds
7603
7777
  */
7604
- function defer(func) {
7605
- return baseDelay(func, 1, arguments, 1);
7606
- }
7778
+ var defer = restParam(function(func, args) {
7779
+ return baseDelay(func, 1, args);
7780
+ });
7607
7781
 
7608
7782
  /**
7609
7783
  * Invokes `func` after `wait` milliseconds. Any additional arguments are
@@ -7623,9 +7797,9 @@
7623
7797
  * }, 1000, 'later');
7624
7798
  * // => logs 'later' after one second
7625
7799
  */
7626
- function delay(func, wait) {
7627
- return baseDelay(func, wait, arguments, 2);
7628
- }
7800
+ var delay = restParam(function(func, wait, args) {
7801
+ return baseDelay(func, wait, args);
7802
+ });
7629
7803
 
7630
7804
  /**
7631
7805
  * Creates a function that returns the result of invoking the provided
@@ -7647,7 +7821,7 @@
7647
7821
  * addSquare(1, 2);
7648
7822
  * // => 9
7649
7823
  */
7650
- var flow = createComposer();
7824
+ var flow = createFlow();
7651
7825
 
7652
7826
  /**
7653
7827
  * This method is like `_.flow` except that it creates a function that
@@ -7669,7 +7843,7 @@
7669
7843
  * addSquare(1, 2);
7670
7844
  * // => 9
7671
7845
  */
7672
- var flowRight = createComposer(true);
7846
+ var flowRight = createFlow(true);
7673
7847
 
7674
7848
  /**
7675
7849
  * Creates a function that memoizes the result of `func`. If `resolver` is
@@ -7681,10 +7855,8 @@
7681
7855
  *
7682
7856
  * **Note:** The cache is exposed as the `cache` property on the memoized
7683
7857
  * function. Its creation may be customized by replacing the `_.memoize.Cache`
7684
- * constructor with one whose instances implement the ES `Map` method interface
7685
- * of `get`, `has`, and `set`. See the
7686
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
7687
- * for more details.
7858
+ * constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
7859
+ * method interface of `get`, `has`, and `set`.
7688
7860
  *
7689
7861
  * @static
7690
7862
  * @memberOf _
@@ -7775,7 +7947,7 @@
7775
7947
  /**
7776
7948
  * Creates a function that is restricted to invoking `func` once. Repeat calls
7777
7949
  * to the function return the value of the first call. The `func` is invoked
7778
- * with the `this` binding of the created function.
7950
+ * with the `this` binding and arguments of the created function.
7779
7951
  *
7780
7952
  * @static
7781
7953
  * @memberOf _
@@ -7808,7 +7980,7 @@
7808
7980
  * @memberOf _
7809
7981
  * @category Function
7810
7982
  * @param {Function} func The function to partially apply arguments to.
7811
- * @param {...*} [args] The arguments to be partially applied.
7983
+ * @param {...*} [partials] The arguments to be partially applied.
7812
7984
  * @returns {Function} Returns the new partially applied function.
7813
7985
  * @example
7814
7986
  *
@@ -7825,12 +7997,7 @@
7825
7997
  * greetFred('hi');
7826
7998
  * // => 'hi fred'
7827
7999
  */
7828
- function partial(func) {
7829
- var partials = baseSlice(arguments, 1),
7830
- holders = replaceHolders(partials, partial.placeholder);
7831
-
7832
- return createWrapper(func, PARTIAL_FLAG, null, partials, holders);
7833
- }
8000
+ var partial = createPartial(PARTIAL_FLAG);
7834
8001
 
7835
8002
  /**
7836
8003
  * This method is like `_.partial` except that partially applied arguments
@@ -7846,7 +8013,7 @@
7846
8013
  * @memberOf _
7847
8014
  * @category Function
7848
8015
  * @param {Function} func The function to partially apply arguments to.
7849
- * @param {...*} [args] The arguments to be partially applied.
8016
+ * @param {...*} [partials] The arguments to be partially applied.
7850
8017
  * @returns {Function} Returns the new partially applied function.
7851
8018
  * @example
7852
8019
  *
@@ -7863,12 +8030,7 @@
7863
8030
  * sayHelloTo('fred');
7864
8031
  * // => 'hello fred'
7865
8032
  */
7866
- function partialRight(func) {
7867
- var partials = baseSlice(arguments, 1),
7868
- holders = replaceHolders(partials, partialRight.placeholder);
7869
-
7870
- return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders);
7871
- }
8033
+ var partialRight = createPartial(PARTIAL_RIGHT_FLAG);
7872
8034
 
7873
8035
  /**
7874
8036
  * Creates a function that invokes `func` with arguments arranged according
@@ -7898,29 +8060,80 @@
7898
8060
  * }, [1, 2, 3]);
7899
8061
  * // => [3, 6, 9]
7900
8062
  */
7901
- function rearg(func) {
7902
- var indexes = baseFlatten(arguments, false, false, 1);
7903
- return createWrapper(func, REARG_FLAG, null, null, null, indexes);
7904
- }
8063
+ var rearg = restParam(function(func, indexes) {
8064
+ return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes));
8065
+ });
7905
8066
 
7906
8067
  /**
7907
8068
  * Creates a function that invokes `func` with the `this` binding of the
7908
- * created function and the array of arguments provided to the created
7909
- * function much like [Function#apply](http://es5.github.io/#x15.3.4.3).
8069
+ * created function and arguments from `start` and beyond provided as an array.
8070
+ *
8071
+ * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
8072
+ *
8073
+ * @static
8074
+ * @memberOf _
8075
+ * @category Function
8076
+ * @param {Function} func The function to apply a rest parameter to.
8077
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
8078
+ * @returns {Function} Returns the new function.
8079
+ * @example
8080
+ *
8081
+ * var say = _.restParam(function(what, names) {
8082
+ * return what + ' ' + _.initial(names).join(', ') +
8083
+ * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
8084
+ * });
8085
+ *
8086
+ * say('hello', 'fred', 'barney', 'pebbles');
8087
+ * // => 'hello fred, barney, & pebbles'
8088
+ */
8089
+ function restParam(func, start) {
8090
+ if (typeof func != 'function') {
8091
+ throw new TypeError(FUNC_ERROR_TEXT);
8092
+ }
8093
+ start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
8094
+ return function() {
8095
+ var args = arguments,
8096
+ index = -1,
8097
+ length = nativeMax(args.length - start, 0),
8098
+ rest = Array(length);
8099
+
8100
+ while (++index < length) {
8101
+ rest[index] = args[start + index];
8102
+ }
8103
+ switch (start) {
8104
+ case 0: return func.call(this, rest);
8105
+ case 1: return func.call(this, args[0], rest);
8106
+ case 2: return func.call(this, args[0], args[1], rest);
8107
+ }
8108
+ var otherArgs = Array(start + 1);
8109
+ index = -1;
8110
+ while (++index < start) {
8111
+ otherArgs[index] = args[index];
8112
+ }
8113
+ otherArgs[start] = rest;
8114
+ return func.apply(this, otherArgs);
8115
+ };
8116
+ }
8117
+
8118
+ /**
8119
+ * Creates a function that invokes `func` with the `this` binding of the created
8120
+ * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
8121
+ *
8122
+ * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).
7910
8123
  *
7911
8124
  * @static
7912
8125
  * @memberOf _
7913
8126
  * @category Function
7914
8127
  * @param {Function} func The function to spread arguments over.
7915
- * @returns {*} Returns the new function.
8128
+ * @returns {Function} Returns the new function.
7916
8129
  * @example
7917
8130
  *
7918
- * var spread = _.spread(function(who, what) {
8131
+ * var say = _.spread(function(who, what) {
7919
8132
  * return who + ' says ' + what;
7920
8133
  * });
7921
8134
  *
7922
- * spread(['Fred', 'hello']);
7923
- * // => 'Fred says hello'
8135
+ * say(['fred', 'hello']);
8136
+ * // => 'fred says hello'
7924
8137
  *
7925
8138
  * // with a Promise
7926
8139
  * var numbers = Promise.all([
@@ -8035,12 +8248,12 @@
8035
8248
  * cloning is handled by the method instead. The `customizer` is bound to
8036
8249
  * `thisArg` and invoked with two argument; (value [, index|key, object]).
8037
8250
  *
8038
- * **Note:** This method is loosely based on the structured clone algorithm.
8251
+ * **Note:** This method is loosely based on the
8252
+ * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
8039
8253
  * The enumerable properties of `arguments` objects and objects created by
8040
8254
  * constructors other than `Object` are cloned to plain `Object` objects. An
8041
8255
  * empty object is returned for uncloneable values such as functions, DOM nodes,
8042
- * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
8043
- * for more details.
8256
+ * Maps, Sets, and WeakMaps.
8044
8257
  *
8045
8258
  * @static
8046
8259
  * @memberOf _
@@ -8098,12 +8311,12 @@
8098
8311
  * is handled by the method instead. The `customizer` is bound to `thisArg`
8099
8312
  * and invoked with two argument; (value [, index|key, object]).
8100
8313
  *
8101
- * **Note:** This method is loosely based on the structured clone algorithm.
8314
+ * **Note:** This method is loosely based on the
8315
+ * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
8102
8316
  * The enumerable properties of `arguments` objects and objects created by
8103
8317
  * constructors other than `Object` are cloned to plain `Object` objects. An
8104
8318
  * empty object is returned for uncloneable values such as functions, DOM nodes,
8105
- * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm)
8106
- * for more details.
8319
+ * Maps, Sets, and WeakMaps.
8107
8320
  *
8108
8321
  * @static
8109
8322
  * @memberOf _
@@ -8160,14 +8373,14 @@
8160
8373
  */
8161
8374
  function isArguments(value) {
8162
8375
  var length = isObjectLike(value) ? value.length : undefined;
8163
- return (isLength(length) && objToString.call(value) == argsTag) || false;
8376
+ return isLength(length) && objToString.call(value) == argsTag;
8164
8377
  }
8165
8378
  // Fallback for environments without a `toStringTag` for `arguments` objects.
8166
8379
  if (!support.argsTag) {
8167
8380
  isArguments = function(value) {
8168
8381
  var length = isObjectLike(value) ? value.length : undefined;
8169
- return (isLength(length) && hasOwnProperty.call(value, 'callee') &&
8170
- !propertyIsEnumerable.call(value, 'callee')) || false;
8382
+ return isLength(length) && hasOwnProperty.call(value, 'callee') &&
8383
+ !propertyIsEnumerable.call(value, 'callee');
8171
8384
  };
8172
8385
  }
8173
8386
 
@@ -8188,7 +8401,7 @@
8188
8401
  * // => false
8189
8402
  */
8190
8403
  var isArray = nativeIsArray || function(value) {
8191
- return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false;
8404
+ return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
8192
8405
  };
8193
8406
 
8194
8407
  /**
@@ -8208,7 +8421,7 @@
8208
8421
  * // => false
8209
8422
  */
8210
8423
  function isBoolean(value) {
8211
- return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false;
8424
+ return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);
8212
8425
  }
8213
8426
 
8214
8427
  /**
@@ -8228,7 +8441,7 @@
8228
8441
  * // => false
8229
8442
  */
8230
8443
  function isDate(value) {
8231
- return (isObjectLike(value) && objToString.call(value) == dateTag) || false;
8444
+ return isObjectLike(value) && objToString.call(value) == dateTag;
8232
8445
  }
8233
8446
 
8234
8447
  /**
@@ -8248,13 +8461,13 @@
8248
8461
  * // => false
8249
8462
  */
8250
8463
  function isElement(value) {
8251
- return (value && value.nodeType === 1 && isObjectLike(value) &&
8252
- (lodash.support.nodeTag ? (objToString.call(value).indexOf('Element') > -1) : isHostObject(value))) || false;
8464
+ return !!value && value.nodeType === 1 && isObjectLike(value) &&
8465
+ (lodash.support.nodeTag ? (objToString.call(value).indexOf('Element') > -1) : isHostObject(value));
8253
8466
  }
8254
8467
  // Fallback for environments without DOM support.
8255
8468
  if (!support.dom) {
8256
8469
  isElement = function(value) {
8257
- return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false;
8470
+ return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
8258
8471
  };
8259
8472
  }
8260
8473
 
@@ -8302,7 +8515,7 @@
8302
8515
  * equivalent. If `customizer` is provided it is invoked to compare values.
8303
8516
  * If `customizer` returns `undefined` comparisons are handled by the method
8304
8517
  * instead. The `customizer` is bound to `thisArg` and invoked with three
8305
- * arguments; (value, other [, index|key]).
8518
+ * arguments: (value, other [, index|key]).
8306
8519
  *
8307
8520
  * **Note:** This method supports comparing arrays, booleans, `Date` objects,
8308
8521
  * numbers, `Object` objects, regexes, and strings. Objects are compared by
@@ -8367,15 +8580,13 @@
8367
8580
  * // => false
8368
8581
  */
8369
8582
  function isError(value) {
8370
- return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false;
8583
+ return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;
8371
8584
  }
8372
8585
 
8373
8586
  /**
8374
8587
  * Checks if `value` is a finite primitive number.
8375
8588
  *
8376
- * **Note:** This method is based on ES `Number.isFinite`. See the
8377
- * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite)
8378
- * for more details.
8589
+ * **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite).
8379
8590
  *
8380
8591
  * @static
8381
8592
  * @memberOf _
@@ -8427,11 +8638,9 @@
8427
8638
  };
8428
8639
 
8429
8640
  /**
8430
- * Checks if `value` is the language type of `Object`.
8641
+ * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
8431
8642
  * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
8432
8643
  *
8433
- * **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details.
8434
- *
8435
8644
  * @static
8436
8645
  * @memberOf _
8437
8646
  * @category Lang
@@ -8452,7 +8661,7 @@
8452
8661
  // Avoid a V8 JIT bug in Chrome 19-20.
8453
8662
  // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
8454
8663
  var type = typeof value;
8455
- return type == 'function' || (value && type == 'object') || false;
8664
+ return type == 'function' || (!!value && type == 'object');
8456
8665
  }
8457
8666
 
8458
8667
  /**
@@ -8460,7 +8669,7 @@
8460
8669
  * `object` contains equivalent property values. If `customizer` is provided
8461
8670
  * it is invoked to compare values. If `customizer` returns `undefined`
8462
8671
  * comparisons are handled by the method instead. The `customizer` is bound
8463
- * to `thisArg` and invoked with three arguments; (value, other, index|key).
8672
+ * to `thisArg` and invoked with three arguments: (value, other, index|key).
8464
8673
  *
8465
8674
  * **Note:** This method supports comparing properties of arrays, booleans,
8466
8675
  * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions
@@ -8498,13 +8707,19 @@
8498
8707
  var props = keys(source),
8499
8708
  length = props.length;
8500
8709
 
8710
+ if (!length) {
8711
+ return true;
8712
+ }
8713
+ if (object == null) {
8714
+ return false;
8715
+ }
8501
8716
  customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
8502
8717
  if (!customizer && length == 1) {
8503
8718
  var key = props[0],
8504
8719
  value = source[key];
8505
8720
 
8506
8721
  if (isStrictComparable(value)) {
8507
- return object != null && value === object[key] && hasOwnProperty.call(object, key);
8722
+ return value === object[key] && (typeof value != 'undefined' || (key in toObject(object)));
8508
8723
  }
8509
8724
  }
8510
8725
  var values = Array(length),
@@ -8514,15 +8729,14 @@
8514
8729
  value = values[length] = source[props[length]];
8515
8730
  strictCompareFlags[length] = isStrictComparable(value);
8516
8731
  }
8517
- return baseIsMatch(object, props, values, strictCompareFlags, customizer);
8732
+ return baseIsMatch(toObject(object), props, values, strictCompareFlags, customizer);
8518
8733
  }
8519
8734
 
8520
8735
  /**
8521
8736
  * Checks if `value` is `NaN`.
8522
8737
  *
8523
- * **Note:** This method is not the same as native `isNaN` which returns `true`
8524
- * for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4)
8525
- * for more details.
8738
+ * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4)
8739
+ * which returns `true` for `undefined` and other non-numeric values.
8526
8740
  *
8527
8741
  * @static
8528
8742
  * @memberOf _
@@ -8572,8 +8786,7 @@
8572
8786
  if (objToString.call(value) == funcTag) {
8573
8787
  return reNative.test(fnToString.call(value));
8574
8788
  }
8575
- return (isObjectLike(value) &&
8576
- (isHostObject(value) ? reNative : reHostCtor).test(value)) || false;
8789
+ return isObjectLike(value) && (isHostObject(value) ? reNative : reHostCtor).test(value);
8577
8790
  }
8578
8791
 
8579
8792
  /**
@@ -8619,7 +8832,7 @@
8619
8832
  * // => false
8620
8833
  */
8621
8834
  function isNumber(value) {
8622
- return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false;
8835
+ return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
8623
8836
  }
8624
8837
 
8625
8838
  /**
@@ -8681,7 +8894,7 @@
8681
8894
  * // => false
8682
8895
  */
8683
8896
  function isRegExp(value) {
8684
- return (isObject(value) && objToString.call(value) == regexpTag) || false;
8897
+ return isObject(value) && objToString.call(value) == regexpTag;
8685
8898
  }
8686
8899
 
8687
8900
  /**
@@ -8701,7 +8914,7 @@
8701
8914
  * // => false
8702
8915
  */
8703
8916
  function isString(value) {
8704
- return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false;
8917
+ return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
8705
8918
  }
8706
8919
 
8707
8920
  /**
@@ -8721,7 +8934,7 @@
8721
8934
  * // => false
8722
8935
  */
8723
8936
  function isTypedArray(value) {
8724
- return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false;
8937
+ return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
8725
8938
  }
8726
8939
 
8727
8940
  /**
@@ -8805,7 +9018,7 @@
8805
9018
  * Assigns own enumerable properties of source object(s) to the destination
8806
9019
  * object. Subsequent sources overwrite property assignments of previous sources.
8807
9020
  * If `customizer` is provided it is invoked to produce the assigned values.
8808
- * The `customizer` is bound to `thisArg` and invoked with five arguments;
9021
+ * The `customizer` is bound to `thisArg` and invoked with five arguments:
8809
9022
  * (objectValue, sourceValue, key, object, source).
8810
9023
  *
8811
9024
  * @static
@@ -8890,18 +9103,18 @@
8890
9103
  * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
8891
9104
  * // => { 'user': 'barney', 'age': 36 }
8892
9105
  */
8893
- function defaults(object) {
9106
+ var defaults = restParam(function(args) {
9107
+ var object = args[0];
8894
9108
  if (object == null) {
8895
9109
  return object;
8896
9110
  }
8897
- var args = arrayCopy(arguments);
8898
9111
  args.push(assignDefaults);
8899
9112
  return assign.apply(undefined, args);
8900
- }
9113
+ });
8901
9114
 
8902
9115
  /**
8903
- * This method is like `_.findIndex` except that it returns the key of the
8904
- * first element `predicate` returns truthy for, instead of the element itself.
9116
+ * This method is like `_.find` except that it returns the key of the first
9117
+ * element `predicate` returns truthy for instead of the element itself.
8905
9118
  *
8906
9119
  * If a property name is provided for `predicate` the created `_.property`
8907
9120
  * style callback returns the property value of the given element.
@@ -8947,10 +9160,7 @@
8947
9160
  * _.findKey(users, 'active');
8948
9161
  * // => 'barney'
8949
9162
  */
8950
- function findKey(object, predicate, thisArg) {
8951
- predicate = getCallback(predicate, thisArg, 3);
8952
- return baseFind(object, predicate, baseForOwn, true);
8953
- }
9163
+ var findKey = createFindKey(baseForOwn);
8954
9164
 
8955
9165
  /**
8956
9166
  * This method is like `_.findKey` except that it iterates over elements of
@@ -9000,15 +9210,12 @@
9000
9210
  * _.findLastKey(users, 'active');
9001
9211
  * // => 'pebbles'
9002
9212
  */
9003
- function findLastKey(object, predicate, thisArg) {
9004
- predicate = getCallback(predicate, thisArg, 3);
9005
- return baseFind(object, predicate, baseForOwnRight, true);
9006
- }
9213
+ var findLastKey = createFindKey(baseForOwnRight);
9007
9214
 
9008
9215
  /**
9009
9216
  * Iterates over own and inherited enumerable properties of an object invoking
9010
9217
  * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked
9011
- * with three arguments; (value, key, object). Iterator functions may exit
9218
+ * with three arguments: (value, key, object). Iterator functions may exit
9012
9219
  * iteration early by explicitly returning `false`.
9013
9220
  *
9014
9221
  * @static
@@ -9032,12 +9239,7 @@
9032
9239
  * });
9033
9240
  * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed)
9034
9241
  */
9035
- function forIn(object, iteratee, thisArg) {
9036
- if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
9037
- iteratee = bindCallback(iteratee, thisArg, 3);
9038
- }
9039
- return baseFor(object, iteratee, keysIn);
9040
- }
9242
+ var forIn = createForIn(baseFor);
9041
9243
 
9042
9244
  /**
9043
9245
  * This method is like `_.forIn` except that it iterates over properties of
@@ -9064,15 +9266,12 @@
9064
9266
  * });
9065
9267
  * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c'
9066
9268
  */
9067
- function forInRight(object, iteratee, thisArg) {
9068
- iteratee = bindCallback(iteratee, thisArg, 3);
9069
- return baseForRight(object, iteratee, keysIn);
9070
- }
9269
+ var forInRight = createForIn(baseForRight);
9071
9270
 
9072
9271
  /**
9073
9272
  * Iterates over own enumerable properties of an object invoking `iteratee`
9074
9273
  * for each property. The `iteratee` is bound to `thisArg` and invoked with
9075
- * three arguments; (value, key, object). Iterator functions may exit iteration
9274
+ * three arguments: (value, key, object). Iterator functions may exit iteration
9076
9275
  * early by explicitly returning `false`.
9077
9276
  *
9078
9277
  * @static
@@ -9096,12 +9295,7 @@
9096
9295
  * });
9097
9296
  * // => logs 'a' and 'b' (iteration order is not guaranteed)
9098
9297
  */
9099
- function forOwn(object, iteratee, thisArg) {
9100
- if (typeof iteratee != 'function' || typeof thisArg != 'undefined') {
9101
- iteratee = bindCallback(iteratee, thisArg, 3);
9102
- }
9103
- return baseForOwn(object, iteratee);
9104
- }
9298
+ var forOwn = createForOwn(baseForOwn);
9105
9299
 
9106
9300
  /**
9107
9301
  * This method is like `_.forOwn` except that it iterates over properties of
@@ -9128,10 +9322,7 @@
9128
9322
  * });
9129
9323
  * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'
9130
9324
  */
9131
- function forOwnRight(object, iteratee, thisArg) {
9132
- iteratee = bindCallback(iteratee, thisArg, 3);
9133
- return baseForRight(object, iteratee, keys);
9134
- }
9325
+ var forOwnRight = createForOwn(baseForOwnRight);
9135
9326
 
9136
9327
  /**
9137
9328
  * Creates an array of function property names from all enumerable properties,
@@ -9345,7 +9536,7 @@
9345
9536
  /**
9346
9537
  * Creates an object with the same keys as `object` and values generated by
9347
9538
  * running each own enumerable property of `object` through `iteratee`. The
9348
- * iteratee function is bound to `thisArg` and invoked with three arguments;
9539
+ * iteratee function is bound to `thisArg` and invoked with three arguments:
9349
9540
  * (value, key, object).
9350
9541
  *
9351
9542
  * If a property name is provided for `iteratee` the created `_.property`
@@ -9400,7 +9591,7 @@
9400
9591
  * provided it is invoked to produce the merged values of the destination and
9401
9592
  * source properties. If `customizer` returns `undefined` merging is handled
9402
9593
  * by the method instead. The `customizer` is bound to `thisArg` and invoked
9403
- * with five arguments; (objectValue, sourceValue, key, object, source).
9594
+ * with five arguments: (objectValue, sourceValue, key, object, source).
9404
9595
  *
9405
9596
  * @static
9406
9597
  * @memberOf _
@@ -9449,7 +9640,7 @@
9449
9640
  * Property names may be specified as individual arguments or as arrays of
9450
9641
  * property names. If `predicate` is provided it is invoked for each property
9451
9642
  * of `object` omitting the properties `predicate` returns truthy for. The
9452
- * predicate is bound to `thisArg` and invoked with three arguments;
9643
+ * predicate is bound to `thisArg` and invoked with three arguments:
9453
9644
  * (value, key, object).
9454
9645
  *
9455
9646
  * @static
@@ -9471,19 +9662,19 @@
9471
9662
  * _.omit(object, _.isNumber);
9472
9663
  * // => { 'user': 'fred' }
9473
9664
  */
9474
- function omit(object, predicate, thisArg) {
9665
+ var omit = restParam(function(object, props) {
9475
9666
  if (object == null) {
9476
9667
  return {};
9477
9668
  }
9478
- if (typeof predicate != 'function') {
9479
- var props = arrayMap(baseFlatten(arguments, false, false, 1), String);
9669
+ if (typeof props[0] != 'function') {
9670
+ var props = arrayMap(baseFlatten(props), String);
9480
9671
  return pickByArray(object, baseDifference(keysIn(object), props));
9481
9672
  }
9482
- predicate = bindCallback(predicate, thisArg, 3);
9673
+ var predicate = bindCallback(props[0], props[1], 3);
9483
9674
  return pickByCallback(object, function(value, key, object) {
9484
9675
  return !predicate(value, key, object);
9485
9676
  });
9486
- }
9677
+ });
9487
9678
 
9488
9679
  /**
9489
9680
  * Creates a two dimensional array of the key-value pairs for `object`,
@@ -9517,7 +9708,7 @@
9517
9708
  * names may be specified as individual arguments or as arrays of property
9518
9709
  * names. If `predicate` is provided it is invoked for each property of `object`
9519
9710
  * picking the properties `predicate` returns truthy for. The predicate is
9520
- * bound to `thisArg` and invoked with three arguments; (value, key, object).
9711
+ * bound to `thisArg` and invoked with three arguments: (value, key, object).
9521
9712
  *
9522
9713
  * @static
9523
9714
  * @memberOf _
@@ -9538,14 +9729,14 @@
9538
9729
  * _.pick(object, _.isString);
9539
9730
  * // => { 'user': 'fred' }
9540
9731
  */
9541
- function pick(object, predicate, thisArg) {
9732
+ var pick = restParam(function(object, props) {
9542
9733
  if (object == null) {
9543
9734
  return {};
9544
9735
  }
9545
- return typeof predicate == 'function'
9546
- ? pickByCallback(object, bindCallback(predicate, thisArg, 3))
9547
- : pickByArray(object, baseFlatten(arguments, false, false, 1));
9548
- }
9736
+ return typeof props[0] == 'function'
9737
+ ? pickByCallback(object, bindCallback(props[0], props[1], 3))
9738
+ : pickByArray(object, baseFlatten(props));
9739
+ });
9549
9740
 
9550
9741
  /**
9551
9742
  * Resolves the value of property `key` on `object`. If the value of `key` is
@@ -9590,7 +9781,7 @@
9590
9781
  * `accumulator` object which is the result of running each of its own enumerable
9591
9782
  * properties through `iteratee`, with each invocation potentially mutating
9592
9783
  * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked
9593
- * with four arguments; (accumulator, value, key, object). Iterator functions
9784
+ * with four arguments: (accumulator, value, key, object). Iterator functions
9594
9785
  * may exit iteration early by explicitly returning `false`.
9595
9786
  *
9596
9787
  * @static
@@ -9801,8 +9992,7 @@
9801
9992
  /*------------------------------------------------------------------------*/
9802
9993
 
9803
9994
  /**
9804
- * Converts `string` to camel case.
9805
- * See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details.
9995
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
9806
9996
  *
9807
9997
  * @static
9808
9998
  * @memberOf _
@@ -9844,9 +10034,8 @@
9844
10034
  }
9845
10035
 
9846
10036
  /**
9847
- * Deburrs `string` by converting latin-1 supplementary letters to basic latin letters.
9848
- * See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
9849
- * for more details.
10037
+ * Deburrs `string` by converting [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
10038
+ * to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
9850
10039
  *
9851
10040
  * @static
9852
10041
  * @memberOf _
@@ -9860,7 +10049,7 @@
9860
10049
  */
9861
10050
  function deburr(string) {
9862
10051
  string = baseToString(string);
9863
- return string && string.replace(reLatin1, deburrLetter);
10052
+ return string && string.replace(reLatin1, deburrLetter).replace(reComboMarks, '');
9864
10053
  }
9865
10054
 
9866
10055
  /**
@@ -9915,9 +10104,8 @@
9915
10104
  * [#108](https://html5sec.org/#108), and [#133](https://html5sec.org/#133) of
9916
10105
  * the [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
9917
10106
  *
9918
- * When working with HTML you should always quote attribute values to reduce
9919
- * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping)
9920
- * for more details.
10107
+ * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping)
10108
+ * to reduce XSS vectors.
9921
10109
  *
9922
10110
  * @static
9923
10111
  * @memberOf _
@@ -9938,8 +10126,8 @@
9938
10126
  }
9939
10127
 
9940
10128
  /**
9941
- * Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*",
9942
- * "+", "(", ")", "[", "]", "{" and "}" in `string`.
10129
+ * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",
10130
+ * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.
9943
10131
  *
9944
10132
  * @static
9945
10133
  * @memberOf _
@@ -9949,7 +10137,7 @@
9949
10137
  * @example
9950
10138
  *
9951
10139
  * _.escapeRegExp('[lodash](https://lodash.com/)');
9952
- * // => '\[lodash\]\(https://lodash\.com/\)'
10140
+ * // => '\[lodash\]\(https:\/\/lodash\.com\/\)'
9953
10141
  */
9954
10142
  function escapeRegExp(string) {
9955
10143
  string = baseToString(string);
@@ -9959,9 +10147,7 @@
9959
10147
  }
9960
10148
 
9961
10149
  /**
9962
- * Converts `string` to kebab case.
9963
- * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for
9964
- * more details.
10150
+ * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
9965
10151
  *
9966
10152
  * @static
9967
10153
  * @memberOf _
@@ -9984,9 +10170,8 @@
9984
10170
  });
9985
10171
 
9986
10172
  /**
9987
- * Pads `string` on the left and right sides if it is shorter then the given
9988
- * padding length. The `chars` string may be truncated if the number of padding
9989
- * characters can't be evenly divided by the padding length.
10173
+ * Pads `string` on the left and right sides if it is shorter than `length`.
10174
+ * Padding characters are truncated if they can't be evenly divided by `length`.
9990
10175
  *
9991
10176
  * @static
9992
10177
  * @memberOf _
@@ -10018,14 +10203,13 @@
10018
10203
  leftLength = floor(mid),
10019
10204
  rightLength = ceil(mid);
10020
10205
 
10021
- chars = createPad('', rightLength, chars);
10206
+ chars = createPadding('', rightLength, chars);
10022
10207
  return chars.slice(0, leftLength) + string + chars;
10023
10208
  }
10024
10209
 
10025
10210
  /**
10026
- * Pads `string` on the left side if it is shorter then the given padding
10027
- * length. The `chars` string may be truncated if the number of padding
10028
- * characters exceeds the padding length.
10211
+ * Pads `string` on the left side if it is shorter than `length`. Padding
10212
+ * characters are truncated if they exceed `length`.
10029
10213
  *
10030
10214
  * @static
10031
10215
  * @memberOf _
@@ -10045,15 +10229,11 @@
10045
10229
  * _.padLeft('abc', 3);
10046
10230
  * // => 'abc'
10047
10231
  */
10048
- function padLeft(string, length, chars) {
10049
- string = baseToString(string);
10050
- return string && (createPad(string, length, chars) + string);
10051
- }
10232
+ var padLeft = createPadDir();
10052
10233
 
10053
10234
  /**
10054
- * Pads `string` on the right side if it is shorter then the given padding
10055
- * length. The `chars` string may be truncated if the number of padding
10056
- * characters exceeds the padding length.
10235
+ * Pads `string` on the right side if it is shorter than `length`. Padding
10236
+ * characters are truncated if they exceed `length`.
10057
10237
  *
10058
10238
  * @static
10059
10239
  * @memberOf _
@@ -10073,18 +10253,15 @@
10073
10253
  * _.padRight('abc', 3);
10074
10254
  * // => 'abc'
10075
10255
  */
10076
- function padRight(string, length, chars) {
10077
- string = baseToString(string);
10078
- return string && (string + createPad(string, length, chars));
10079
- }
10256
+ var padRight = createPadDir(true);
10080
10257
 
10081
10258
  /**
10082
10259
  * Converts `string` to an integer of the specified radix. If `radix` is
10083
10260
  * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
10084
10261
  * in which case a `radix` of `16` is used.
10085
10262
  *
10086
- * **Note:** This method aligns with the ES5 implementation of `parseInt`.
10087
- * See the [ES5 spec](https://es5.github.io/#E) for more details.
10263
+ * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E)
10264
+ * of `parseInt`.
10088
10265
  *
10089
10266
  * @static
10090
10267
  * @memberOf _
@@ -10164,8 +10341,7 @@
10164
10341
  }
10165
10342
 
10166
10343
  /**
10167
- * Converts `string` to snake case.
10168
- * See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details.
10344
+ * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case).
10169
10345
  *
10170
10346
  * @static
10171
10347
  * @memberOf _
@@ -10188,9 +10364,7 @@
10188
10364
  });
10189
10365
 
10190
10366
  /**
10191
- * Converts `string` to start case.
10192
- * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
10193
- * for more details.
10367
+ * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
10194
10368
  *
10195
10369
  * @static
10196
10370
  * @memberOf _
@@ -10249,9 +10423,9 @@
10249
10423
  * properties may be accessed as free variables in the template. If a setting
10250
10424
  * object is provided it takes precedence over `_.templateSettings` values.
10251
10425
  *
10252
- * **Note:** In the development build `_.template` utilizes sourceURLs for easier debugging.
10253
- * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
10254
- * for more details.
10426
+ * **Note:** In the development build `_.template` utilizes
10427
+ * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
10428
+ * for easier debugging.
10255
10429
  *
10256
10430
  * For more information on precompiling templates see
10257
10431
  * [lodash's custom builds documentation](https://lodash.com/custom-builds).
@@ -10463,7 +10637,7 @@
10463
10637
  * // => 'abc'
10464
10638
  *
10465
10639
  * _.map([' foo ', ' bar '], _.trim);
10466
- * // => ['foo', 'bar]
10640
+ * // => ['foo', 'bar']
10467
10641
  */
10468
10642
  function trim(string, chars, guard) {
10469
10643
  var value = string;
@@ -10571,7 +10745,7 @@
10571
10745
  * 'length': 24,
10572
10746
  * 'separator': /,? +/
10573
10747
  * });
10574
- * //=> 'hi-diddly-ho there...'
10748
+ * // => 'hi-diddly-ho there...'
10575
10749
  *
10576
10750
  * _.trunc('hi-diddly-ho there, neighborino', {
10577
10751
  * 'omission': ' [...]'
@@ -10690,7 +10864,7 @@
10690
10864
  * @static
10691
10865
  * @memberOf _
10692
10866
  * @category Utility
10693
- * @param {*} func The function to attempt.
10867
+ * @param {Function} func The function to attempt.
10694
10868
  * @returns {*} Returns the `func` result or error object.
10695
10869
  * @example
10696
10870
  *
@@ -10703,20 +10877,13 @@
10703
10877
  * elements = [];
10704
10878
  * }
10705
10879
  */
10706
- function attempt() {
10707
- var func = arguments[0],
10708
- length = arguments.length,
10709
- args = Array(length ? (length - 1) : 0);
10710
-
10711
- while (--length > 0) {
10712
- args[length - 1] = arguments[length];
10713
- }
10880
+ var attempt = restParam(function(func, args) {
10714
10881
  try {
10715
10882
  return func.apply(undefined, args);
10716
10883
  } catch(e) {
10717
10884
  return isError(e) ? e : new Error(e);
10718
10885
  }
10719
- }
10886
+ });
10720
10887
 
10721
10888
  /**
10722
10889
  * Creates a function that invokes `func` with the `this` binding of `thisArg`
@@ -10853,12 +11020,11 @@
10853
11020
  *
10854
11021
  * var users = [
10855
11022
  * { 'user': 'barney' },
10856
- * { 'user': 'fred' },
10857
- * { 'user': 'pebbles' }
11023
+ * { 'user': 'fred' }
10858
11024
  * ];
10859
11025
  *
10860
11026
  * _.find(users, _.matchesProperty('user', 'fred'));
10861
- * // => { 'user': 'fred', 'age': 40 }
11027
+ * // => { 'user': 'fred' }
10862
11028
  */
10863
11029
  function matchesProperty(key, value) {
10864
11030
  return baseMatchesProperty(key + '', baseClone(value, true));
@@ -10869,6 +11035,9 @@
10869
11035
  * destination object. If `object` is a function then methods are added to
10870
11036
  * its prototype as well.
10871
11037
  *
11038
+ * **Note:** Use `_.runInContext` to create a pristine `lodash` function
11039
+ * for mixins to avoid conflicts caused by modifying the original.
11040
+ *
10872
11041
  * @static
10873
11042
  * @memberOf _
10874
11043
  * @category Utility
@@ -10886,7 +11055,7 @@
10886
11055
  * });
10887
11056
  * }
10888
11057
  *
10889
- * // use `_.runInContext` to avoid potential conflicts (esp. in Node.js)
11058
+ * // use `_.runInContext` to avoid conflicts (esp. in Node.js)
10890
11059
  * var _ = require('lodash').runInContext();
10891
11060
  *
10892
11061
  * _.mixin({ 'vowels': vowels });
@@ -10936,12 +11105,10 @@
10936
11105
  return function() {
10937
11106
  var chainAll = this.__chain__;
10938
11107
  if (chain || chainAll) {
10939
- var result = object(this.__wrapped__);
10940
- (result.__actions__ = arrayCopy(this.__actions__)).push({
10941
- 'func': func,
10942
- 'args': arguments,
10943
- 'thisArg': object
10944
- });
11108
+ var result = object(this.__wrapped__),
11109
+ actions = result.__actions__ = arrayCopy(this.__actions__);
11110
+
11111
+ actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
10945
11112
  result.__chain__ = chainAll;
10946
11113
  return result;
10947
11114
  }
@@ -11008,7 +11175,7 @@
11008
11175
  * var getName = _.property('user');
11009
11176
  *
11010
11177
  * _.map(users, getName);
11011
- * // => ['fred', barney']
11178
+ * // => ['fred', 'barney']
11012
11179
  *
11013
11180
  * _.pluck(_.sortBy(users, getName), 'user');
11014
11181
  * // => ['barney', 'fred']
@@ -11018,7 +11185,7 @@
11018
11185
  }
11019
11186
 
11020
11187
  /**
11021
- * The inverse of `_.property`; this method creates a function which returns
11188
+ * The opposite of `_.property`; this method creates a function which returns
11022
11189
  * the property value of a given key on `object`.
11023
11190
  *
11024
11191
  * @static
@@ -11196,16 +11363,16 @@
11196
11363
  * `-Infinity` is returned. If an iteratee function is provided it is invoked
11197
11364
  * for each value in `collection` to generate the criterion by which the value
11198
11365
  * is ranked. The `iteratee` is bound to `thisArg` and invoked with three
11199
- * arguments; (value, index, collection).
11366
+ * arguments: (value, index, collection).
11200
11367
  *
11201
- * If a property name is provided for `predicate` the created `_.property`
11368
+ * If a property name is provided for `iteratee` the created `_.property`
11202
11369
  * style callback returns the property value of the given element.
11203
11370
  *
11204
11371
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
11205
11372
  * style callback returns `true` for elements that have a matching property
11206
11373
  * value, else `false`.
11207
11374
  *
11208
- * If an object is provided for `predicate` the created `_.matches` style
11375
+ * If an object is provided for `iteratee` the created `_.matches` style
11209
11376
  * callback returns `true` for elements that have the properties of the given
11210
11377
  * object, else `false`.
11211
11378
  *
@@ -11232,11 +11399,11 @@
11232
11399
  * _.max(users, function(chr) {
11233
11400
  * return chr.age;
11234
11401
  * });
11235
- * // => { 'user': 'fred', 'age': 40 };
11402
+ * // => { 'user': 'fred', 'age': 40 }
11236
11403
  *
11237
11404
  * // using the `_.property` callback shorthand
11238
11405
  * _.max(users, 'age');
11239
- * // => { 'user': 'fred', 'age': 40 };
11406
+ * // => { 'user': 'fred', 'age': 40 }
11240
11407
  */
11241
11408
  var max = createExtremum(arrayMax);
11242
11409
 
@@ -11245,16 +11412,16 @@
11245
11412
  * `Infinity` is returned. If an iteratee function is provided it is invoked
11246
11413
  * for each value in `collection` to generate the criterion by which the value
11247
11414
  * is ranked. The `iteratee` is bound to `thisArg` and invoked with three
11248
- * arguments; (value, index, collection).
11415
+ * arguments: (value, index, collection).
11249
11416
  *
11250
- * If a property name is provided for `predicate` the created `_.property`
11417
+ * If a property name is provided for `iteratee` the created `_.property`
11251
11418
  * style callback returns the property value of the given element.
11252
11419
  *
11253
11420
  * If a value is also provided for `thisArg` the created `_.matchesProperty`
11254
11421
  * style callback returns `true` for elements that have a matching property
11255
11422
  * value, else `false`.
11256
11423
  *
11257
- * If an object is provided for `predicate` the created `_.matches` style
11424
+ * If an object is provided for `iteratee` the created `_.matches` style
11258
11425
  * callback returns `true` for elements that have the properties of the given
11259
11426
  * object, else `false`.
11260
11427
  *
@@ -11281,11 +11448,11 @@
11281
11448
  * _.min(users, function(chr) {
11282
11449
  * return chr.age;
11283
11450
  * });
11284
- * // => { 'user': 'barney', 'age': 36 };
11451
+ * // => { 'user': 'barney', 'age': 36 }
11285
11452
  *
11286
11453
  * // using the `_.property` callback shorthand
11287
11454
  * _.min(users, 'age');
11288
- * // => { 'user': 'barney', 'age': 36 };
11455
+ * // => { 'user': 'barney', 'age': 36 }
11289
11456
  */
11290
11457
  var min = createExtremum(arrayMin, true);
11291
11458
 
@@ -11296,26 +11463,45 @@
11296
11463
  * @memberOf _
11297
11464
  * @category Math
11298
11465
  * @param {Array|Object|string} collection The collection to iterate over.
11466
+ * @param {Function|Object|string} [iteratee] The function invoked per iteration.
11467
+ * @param {*} [thisArg] The `this` binding of `iteratee`.
11299
11468
  * @returns {number} Returns the sum.
11300
11469
  * @example
11301
11470
  *
11302
- * _.sum([4, 6, 2]);
11303
- * // => 12
11471
+ * _.sum([4, 6]);
11472
+ * // => 10
11473
+ *
11474
+ * _.sum({ 'a': 4, 'b': 6 });
11475
+ * // => 10
11476
+ *
11477
+ * var objects = [
11478
+ * { 'n': 4 },
11479
+ * { 'n': 6 }
11480
+ * ];
11481
+ *
11482
+ * _.sum(objects, function(object) {
11483
+ * return object.n;
11484
+ * });
11485
+ * // => 10
11304
11486
  *
11305
- * _.sum({ 'a': 4, 'b': 6, 'c': 2 });
11306
- * // => 12
11487
+ * // using the `_.property` callback shorthand
11488
+ * _.sum(objects, 'n');
11489
+ * // => 10
11307
11490
  */
11308
- function sum(collection) {
11309
- if (!isArray(collection)) {
11310
- collection = toIterable(collection);
11491
+ function sum(collection, iteratee, thisArg) {
11492
+ if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
11493
+ iteratee = null;
11311
11494
  }
11312
- var length = collection.length,
11313
- result = 0;
11495
+ var func = getCallback(),
11496
+ noIteratee = iteratee == null;
11314
11497
 
11315
- while (length--) {
11316
- result += +collection[length] || 0;
11498
+ if (!(func === baseCallback && noIteratee)) {
11499
+ noIteratee = false;
11500
+ iteratee = func(iteratee, thisArg, 3);
11317
11501
  }
11318
- return result;
11502
+ return noIteratee
11503
+ ? arraySum(isArray(collection) ? collection : toIterable(collection))
11504
+ : baseSum(collection, iteratee);
11319
11505
  }
11320
11506
 
11321
11507
  /*------------------------------------------------------------------------*/
@@ -11414,6 +11600,7 @@
11414
11600
  lodash.reject = reject;
11415
11601
  lodash.remove = remove;
11416
11602
  lodash.rest = rest;
11603
+ lodash.restParam = restParam;
11417
11604
  lodash.shuffle = shuffle;
11418
11605
  lodash.slice = slice;
11419
11606
  lodash.sortBy = sortBy;
@@ -11705,8 +11892,11 @@
11705
11892
 
11706
11893
  // Add `LazyWrapper` methods to `lodash.prototype`.
11707
11894
  baseForOwn(LazyWrapper.prototype, function(func, methodName) {
11708
- var lodashFunc = lodash[methodName],
11709
- checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
11895
+ var lodashFunc = lodash[methodName];
11896
+ if (!lodashFunc) {
11897
+ return;
11898
+ }
11899
+ var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),
11710
11900
  retUnwrapped = /^(?:first|last)$/.test(methodName);
11711
11901
 
11712
11902
  lodash.prototype[methodName] = function() {
@@ -11776,6 +11966,19 @@
11776
11966
  };
11777
11967
  });
11778
11968
 
11969
+ // Map minified function names to their real names.
11970
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
11971
+ var lodashFunc = lodash[methodName];
11972
+ if (lodashFunc) {
11973
+ var key = lodashFunc.name,
11974
+ names = realNames[key] || (realNames[key] = []);
11975
+
11976
+ names.push({ 'name': methodName, 'func': lodashFunc });
11977
+ }
11978
+ });
11979
+
11980
+ realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }];
11981
+
11779
11982
  // Add functions to the lazy wrapper.
11780
11983
  LazyWrapper.prototype.clone = lazyClone;
11781
11984
  LazyWrapper.prototype.reverse = lazyReverse;