lodash-rails 3.1.0 → 3.2.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: a21711a7328e1a28ae9041bf34e77e31b90b1375
4
- data.tar.gz: 4d43acec1388718584e302da0476ee91d7657798
3
+ metadata.gz: 65466937463572ed6cc01088daa13ada4dd3c6ae
4
+ data.tar.gz: 3371d3bfc449a68a53034027fed13bbaa4af0c07
5
5
  SHA512:
6
- metadata.gz: 6a87325eca740138328bdbdd699f3477fbb2fa176be98fd496c41a0ff5f5c3da11e14a2e58ba7222573bae25e1babac4f72513e95afbf1dc2600d099ab1fa307
7
- data.tar.gz: 99f3bf92806819d8a3ce1416308834cda5918e5b1b15e1df8462aae8617cc2538afff9cc73c297e95e3bcdefc2e6288a9d6c07a8877c5406c4b5f63545d4d1a3
6
+ metadata.gz: 6ab1afec36e5853e710330452ed00db00f03eb119fb50ce8064ff8ae81871cd092dc2770ef39838571b7ec515fe473ca12380b9c53c9fc2ef72d1eb369248a45
7
+ data.tar.gz: 5171e281f3b0616ddce94dc6fe38e67460c609a667165148bdd11b73d49378c3c66c6d7bc88a982da77a8e80f5f1f7675ea374f2087c38aed21277e288f36b49
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # lodash-rails
2
2
 
3
- [Lo-Dash](http://lodash.com/) for the Rails asset pipeline.
3
+ [lodash](http://lodash.com/) for the Rails asset pipeline.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,11 +18,9 @@ Add the necessary library to `app/assets/javascripts/application.js`:
18
18
 
19
19
  ## What's included?
20
20
 
21
- Lo-Dash 3.1.0:
21
+ lodash 3.2.0:
22
22
 
23
23
  * lodash.js
24
24
  * lodash.min.js
25
- * lodash.compat.js
26
- * lodash.compat.min.js
27
25
 
28
26
  Copyright Richard Hubers, released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  module LoDash
2
2
  module Rails
3
- VERSION = "3.1.0"
3
+ VERSION = "3.2.0"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * lodash 3.1.0 (Custom Build) <https://lodash.com/>
3
+ * lodash 3.2.0 (Custom Build) <https://lodash.com/>
4
4
  * Build: `lodash modern -o ./lodash.js`
5
5
  * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
6
6
  * Based on Underscore.js 1.7.0 <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.1.0';
16
+ var VERSION = '3.2.0';
17
17
 
18
18
  /** Used to compose bitmasks for wrapper metadata. */
19
19
  var BIND_FLAG = 1,
@@ -728,7 +728,6 @@
728
728
  setTimeout = context.setTimeout,
729
729
  splice = arrayProto.splice,
730
730
  Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array,
731
- unshift = arrayProto.unshift,
732
731
  WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap;
733
732
 
734
733
  /** Used to clone array buffers. */
@@ -780,7 +779,7 @@
780
779
  /*------------------------------------------------------------------------*/
781
780
 
782
781
  /**
783
- * Creates a `lodash` object which wraps `value` to enable intuitive chaining.
782
+ * Creates a `lodash` object which wraps `value` to enable implicit chaining.
784
783
  * Methods that operate on and return arrays, collections, and functions can
785
784
  * be chained together. Methods that return a boolean or single value will
786
785
  * automatically end the chain returning the unwrapped value. Explicit chaining
@@ -799,29 +798,31 @@
799
798
  * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
800
799
  * and `unshift`
801
800
  *
802
- * The wrapper functions that support shortcut fusion are:
803
- * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`,
804
- * `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`,
805
- * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where`
801
+ * The wrapper methods that support shortcut fusion are:
802
+ * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
803
+ * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
804
+ * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
805
+ * and `where`
806
806
  *
807
- * The chainable wrapper functions are:
807
+ * The chainable wrapper methods are:
808
808
  * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
809
- * `callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`,
810
- * `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`,
811
- * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `flatten`,
812
- * `flattenDeep`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`,
813
- * `forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`,
814
- * `initial`, `intersection`, `invert`, `invoke`, `keys`, `keysIn`, `map`,
815
- * `mapValues`, `matches`, `memoize`, `merge`, `mixin`, `negate`, `noop`,
816
- * `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`,
817
- * `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`,
818
- * `rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
819
- * `sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`,
820
- * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,
821
- * `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`,
822
- * `where`, `without`, `wrap`, `xor`, `zip`, and `zipObject`
823
- *
824
- * The wrapper functions that are **not** chainable by default are:
809
+ * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
810
+ * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,
811
+ * `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,
812
+ * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
813
+ * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
814
+ * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
815
+ * `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`,
816
+ * `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
817
+ * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
818
+ * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
819
+ * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`,
820
+ * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
821
+ * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,
822
+ * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`,
823
+ * `zip`, and `zipObject`
824
+ *
825
+ * The wrapper methods that are **not** chainable by default are:
825
826
  * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
826
827
  * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
827
828
  * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
@@ -836,14 +837,14 @@
836
837
  * `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`,
837
838
  * `trunc`, `unescape`, `uniqueId`, `value`, and `words`
838
839
  *
839
- * The wrapper function `sample` will return a wrapped value when `n` is provided,
840
+ * The wrapper method `sample` will return a wrapped value when `n` is provided,
840
841
  * otherwise an unwrapped value is returned.
841
842
  *
842
843
  * @name _
843
844
  * @constructor
844
845
  * @category Chain
845
846
  * @param {*} value The value to wrap in a `lodash` instance.
846
- * @returns {Object} Returns a `lodash` instance.
847
+ * @returns {Object} Returns the new `lodash` wrapper instance.
847
848
  * @example
848
849
  *
849
850
  * var wrapped = _([1, 2, 3]);
@@ -862,12 +863,12 @@
862
863
  * // => true
863
864
  */
864
865
  function lodash(value) {
865
- if (isObjectLike(value) && !isArray(value)) {
866
+ if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
866
867
  if (value instanceof LodashWrapper) {
867
868
  return value;
868
869
  }
869
- if (hasOwnProperty.call(value, '__wrapped__')) {
870
- return new LodashWrapper(value.__wrapped__, value.__chain__, arrayCopy(value.__actions__));
870
+ if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
871
+ return wrapperClone(value);
871
872
  }
872
873
  }
873
874
  return new LodashWrapper(value);
@@ -882,9 +883,9 @@
882
883
  * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
883
884
  */
884
885
  function LodashWrapper(value, chainAll, actions) {
886
+ this.__wrapped__ = value;
885
887
  this.__actions__ = actions || [];
886
888
  this.__chain__ = !!chainAll;
887
- this.__wrapped__ = value;
888
889
  }
889
890
 
890
891
  /**
@@ -1017,14 +1018,14 @@
1017
1018
  * @param {*} value The value to wrap.
1018
1019
  */
1019
1020
  function LazyWrapper(value) {
1020
- this.actions = null;
1021
- this.dir = 1;
1022
- this.dropCount = 0;
1023
- this.filtered = false;
1024
- this.iteratees = null;
1025
- this.takeCount = POSITIVE_INFINITY;
1026
- this.views = null;
1027
- this.wrapped = value;
1021
+ this.__wrapped__ = value;
1022
+ this.__actions__ = null;
1023
+ this.__dir__ = 1;
1024
+ this.__dropCount__ = 0;
1025
+ this.__filtered__ = false;
1026
+ this.__iteratees__ = null;
1027
+ this.__takeCount__ = POSITIVE_INFINITY;
1028
+ this.__views__ = null;
1028
1029
  }
1029
1030
 
1030
1031
  /**
@@ -1036,18 +1037,18 @@
1036
1037
  * @returns {Object} Returns the cloned `LazyWrapper` object.
1037
1038
  */
1038
1039
  function lazyClone() {
1039
- var actions = this.actions,
1040
- iteratees = this.iteratees,
1041
- views = this.views,
1042
- result = new LazyWrapper(this.wrapped);
1043
-
1044
- result.actions = actions ? arrayCopy(actions) : null;
1045
- result.dir = this.dir;
1046
- result.dropCount = this.dropCount;
1047
- result.filtered = this.filtered;
1048
- result.iteratees = iteratees ? arrayCopy(iteratees) : null;
1049
- result.takeCount = this.takeCount;
1050
- result.views = views ? arrayCopy(views) : null;
1040
+ var actions = this.__actions__,
1041
+ iteratees = this.__iteratees__,
1042
+ views = this.__views__,
1043
+ result = new LazyWrapper(this.__wrapped__);
1044
+
1045
+ result.__actions__ = actions ? arrayCopy(actions) : null;
1046
+ result.__dir__ = this.__dir__;
1047
+ result.__dropCount__ = this.__dropCount__;
1048
+ result.__filtered__ = this.__filtered__;
1049
+ result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
1050
+ result.__takeCount__ = this.__takeCount__;
1051
+ result.__views__ = views ? arrayCopy(views) : null;
1051
1052
  return result;
1052
1053
  }
1053
1054
 
@@ -1060,13 +1061,13 @@
1060
1061
  * @returns {Object} Returns the new reversed `LazyWrapper` object.
1061
1062
  */
1062
1063
  function lazyReverse() {
1063
- if (this.filtered) {
1064
+ if (this.__filtered__) {
1064
1065
  var result = new LazyWrapper(this);
1065
- result.dir = -1;
1066
- result.filtered = true;
1066
+ result.__dir__ = -1;
1067
+ result.__filtered__ = true;
1067
1068
  } else {
1068
1069
  result = this.clone();
1069
- result.dir *= -1;
1070
+ result.__dir__ *= -1;
1070
1071
  }
1071
1072
  return result;
1072
1073
  }
@@ -1080,20 +1081,20 @@
1080
1081
  * @returns {*} Returns the unwrapped value.
1081
1082
  */
1082
1083
  function lazyValue() {
1083
- var array = this.wrapped.value();
1084
+ var array = this.__wrapped__.value();
1084
1085
  if (!isArray(array)) {
1085
- return baseWrapperValue(array, this.actions);
1086
+ return baseWrapperValue(array, this.__actions__);
1086
1087
  }
1087
- var dir = this.dir,
1088
+ var dir = this.__dir__,
1088
1089
  isRight = dir < 0,
1089
- view = getView(0, array.length, this.views),
1090
+ view = getView(0, array.length, this.__views__),
1090
1091
  start = view.start,
1091
1092
  end = view.end,
1092
1093
  length = end - start,
1093
- dropCount = this.dropCount,
1094
- takeCount = nativeMin(length, this.takeCount - dropCount),
1094
+ dropCount = this.__dropCount__,
1095
+ takeCount = nativeMin(length, this.__takeCount__),
1095
1096
  index = isRight ? end : start - 1,
1096
- iteratees = this.iteratees,
1097
+ iteratees = this.__iteratees__,
1097
1098
  iterLength = iteratees ? iteratees.length : 0,
1098
1099
  resIndex = 0,
1099
1100
  result = [];
@@ -1538,7 +1539,7 @@
1538
1539
  return baseCopy(source, object, props);
1539
1540
  }
1540
1541
  var index = -1,
1541
- length = props.length
1542
+ length = props.length;
1542
1543
 
1543
1544
  while (++index < length) {
1544
1545
  var key = props[index],
@@ -1645,10 +1646,12 @@
1645
1646
  if (func == null) {
1646
1647
  return identity;
1647
1648
  }
1648
- // Handle "_.property" and "_.matches" style callback shorthands.
1649
- return type == 'object'
1650
- ? baseMatches(func)
1651
- : baseProperty(func + '');
1649
+ if (type == 'object') {
1650
+ return baseMatches(func);
1651
+ }
1652
+ return typeof thisArg == 'undefined'
1653
+ ? baseProperty(func + '')
1654
+ : baseMatchesProperty(func + '', thisArg);
1652
1655
  }
1653
1656
 
1654
1657
  /**
@@ -1749,7 +1752,7 @@
1749
1752
  * @returns {number} Returns the timer id.
1750
1753
  */
1751
1754
  function baseDelay(func, wait, args, fromIndex) {
1752
- if (!isFunction(func)) {
1755
+ if (typeof func != 'function') {
1753
1756
  throw new TypeError(FUNC_ERROR_TEXT);
1754
1757
  }
1755
1758
  return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait);
@@ -1869,6 +1872,36 @@
1869
1872
  return result;
1870
1873
  }
1871
1874
 
1875
+ /**
1876
+ * The base implementation of `_.fill` without an iteratee call guard.
1877
+ *
1878
+ * @private
1879
+ * @param {Array} array The array to fill.
1880
+ * @param {*} value The value to fill `array` with.
1881
+ * @param {number} [start=0] The start position.
1882
+ * @param {number} [end=array.length] The end position.
1883
+ * @returns {Array} Returns `array`.
1884
+ */
1885
+ function baseFill(array, value, start, end) {
1886
+ var length = array.length;
1887
+
1888
+ start = start == null ? 0 : (+start || 0);
1889
+ if (start < 0) {
1890
+ start = -start > length ? 0 : (length + start);
1891
+ }
1892
+ end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
1893
+ if (end < 0) {
1894
+ end += length;
1895
+ }
1896
+ length = start > end ? 0 : end >>> 0;
1897
+ start >>>= 0;
1898
+
1899
+ while (start < length) {
1900
+ array[start++] = value;
1901
+ }
1902
+ return array;
1903
+ }
1904
+
1872
1905
  /**
1873
1906
  * The base implementation of `_.filter` without support for callback
1874
1907
  * shorthands or `this` binding.
@@ -2201,7 +2234,7 @@
2201
2234
  * shorthands or `this` binding.
2202
2235
  *
2203
2236
  * @private
2204
- * @param {Object} source The object to inspect.
2237
+ * @param {Object} object The object to inspect.
2205
2238
  * @param {Array} props The source property names to match.
2206
2239
  * @param {Array} values The source values to match.
2207
2240
  * @param {Array} strictCompareFlags Strict comparison flags for source values.
@@ -2263,8 +2296,7 @@
2263
2296
  }
2264
2297
 
2265
2298
  /**
2266
- * The base implementation of `_.matches` which supports specifying whether
2267
- * `source` should be cloned.
2299
+ * The base implementation of `_.matches` which does not clone `source`.
2268
2300
  *
2269
2301
  * @private
2270
2302
  * @param {Object} source The object of property values to match.
@@ -2297,6 +2329,26 @@
2297
2329
  };
2298
2330
  }
2299
2331
 
2332
+ /**
2333
+ * The base implementation of `_.matchesProperty` which does not coerce `key`
2334
+ * to a string.
2335
+ *
2336
+ * @private
2337
+ * @param {string} key The key of the property to get.
2338
+ * @param {*} value The value to compare.
2339
+ * @returns {Function} Returns the new function.
2340
+ */
2341
+ function baseMatchesProperty(key, value) {
2342
+ if (isStrictComparable(value)) {
2343
+ return function(object) {
2344
+ return object != null && object[key] === value;
2345
+ };
2346
+ }
2347
+ return function(object) {
2348
+ return object != null && baseIsEqual(value, object[key], null, true);
2349
+ };
2350
+ }
2351
+
2300
2352
  /**
2301
2353
  * The base implementation of `_.merge` without support for argument juggling,
2302
2354
  * multiple sources, and `this` binding `customizer` functions.
@@ -2459,7 +2511,7 @@
2459
2511
  eachFunc(collection, function(value, index, collection) {
2460
2512
  accumulator = initFromCollection
2461
2513
  ? (initFromCollection = false, value)
2462
- : iteratee(accumulator, value, index, collection)
2514
+ : iteratee(accumulator, value, index, collection);
2463
2515
  });
2464
2516
  return accumulator;
2465
2517
  }
@@ -2835,8 +2887,7 @@
2835
2887
  /**
2836
2888
  * Creates a function that aggregates a collection, creating an accumulator
2837
2889
  * object composed from the results of running each element in the collection
2838
- * through an iteratee. The `setter` sets the keys and values of the accumulator
2839
- * object. If `initializer` is provided initializes the accumulator object.
2890
+ * through an iteratee.
2840
2891
  *
2841
2892
  * @private
2842
2893
  * @param {Function} setter The function to set keys and values of the accumulator object.
@@ -3173,7 +3224,7 @@
3173
3224
  */
3174
3225
  function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
3175
3226
  var isBindKey = bitmask & BIND_KEY_FLAG;
3176
- if (!isBindKey && !isFunction(func)) {
3227
+ if (!isBindKey && typeof func != 'function') {
3177
3228
  throw new TypeError(FUNC_ERROR_TEXT);
3178
3229
  }
3179
3230
  var length = partials ? partials.length : 0;
@@ -3203,9 +3254,9 @@
3203
3254
  if (bitmask == BIND_FLAG) {
3204
3255
  var result = createBindWrapper(newData[0], newData[2]);
3205
3256
  } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
3206
- result = createPartialWrapper.apply(null, newData);
3257
+ result = createPartialWrapper.apply(undefined, newData);
3207
3258
  } else {
3208
- result = createHybridWrapper.apply(null, newData);
3259
+ result = createHybridWrapper.apply(undefined, newData);
3209
3260
  }
3210
3261
  var setter = data ? baseSetData : setData;
3211
3262
  return setter(result, newData);
@@ -3893,6 +3944,19 @@
3893
3944
  return isObject(value) ? value : Object(value);
3894
3945
  }
3895
3946
 
3947
+ /**
3948
+ * Creates a clone of `wrapper`.
3949
+ *
3950
+ * @private
3951
+ * @param {Object} wrapper The wrapper to clone.
3952
+ * @returns {Object} Returns the cloned wrapper.
3953
+ */
3954
+ function wrapperClone(wrapper) {
3955
+ return wrapper instanceof LazyWrapper
3956
+ ? wrapper.clone()
3957
+ : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
3958
+ }
3959
+
3896
3960
  /*------------------------------------------------------------------------*/
3897
3961
 
3898
3962
  /**
@@ -3904,7 +3968,7 @@
3904
3968
  * @memberOf _
3905
3969
  * @category Array
3906
3970
  * @param {Array} array The array to process.
3907
- * @param {numer} [size=1] The length of each chunk.
3971
+ * @param {number} [size=1] The length of each chunk.
3908
3972
  * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
3909
3973
  * @returns {Array} Returns the new array containing chunks.
3910
3974
  * @example
@@ -3999,7 +4063,6 @@
3999
4063
  *
4000
4064
  * @static
4001
4065
  * @memberOf _
4002
- * @type Function
4003
4066
  * @category Array
4004
4067
  * @param {Array} array The array to query.
4005
4068
  * @param {number} [n=1] The number of elements to drop.
@@ -4035,7 +4098,6 @@
4035
4098
  *
4036
4099
  * @static
4037
4100
  * @memberOf _
4038
- * @type Function
4039
4101
  * @category Array
4040
4102
  * @param {Array} array The array to query.
4041
4103
  * @param {number} [n=1] The number of elements to drop.
@@ -4075,13 +4137,16 @@
4075
4137
  * If a property name is provided for `predicate` the created "_.property"
4076
4138
  * style callback returns the property value of the given element.
4077
4139
  *
4140
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4141
+ * style callback returns `true` for elements that have a matching property
4142
+ * value, else `false`.
4143
+ *
4078
4144
  * If an object is provided for `predicate` the created "_.matches" style
4079
- * callback returns `true` for elements that have the properties of the given
4145
+ * callback returns `true` for elements that match the properties of the given
4080
4146
  * object, else `false`.
4081
4147
  *
4082
4148
  * @static
4083
4149
  * @memberOf _
4084
- * @type Function
4085
4150
  * @category Array
4086
4151
  * @param {Array} array The array to query.
4087
4152
  * @param {Function|Object|string} [predicate=_.identity] The function invoked
@@ -4094,18 +4159,22 @@
4094
4159
  * // => [1]
4095
4160
  *
4096
4161
  * var users = [
4097
- * { 'user': 'barney', 'status': 'busy', 'active': false },
4098
- * { 'user': 'fred', 'status': 'busy', 'active': true },
4099
- * { 'user': 'pebbles', 'status': 'away', 'active': true }
4162
+ * { 'user': 'barney', 'age': 36, 'active': true },
4163
+ * { 'user': 'fred', 'age': 40, 'active': false },
4164
+ * { 'user': 'pebbles', 'age': 1, 'active': false }
4100
4165
  * ];
4101
4166
  *
4102
- * // using the "_.property" callback shorthand
4103
- * _.pluck(_.dropRightWhile(users, 'active'), 'user');
4104
- * // => ['barney']
4105
- *
4106
4167
  * // using the "_.matches" callback shorthand
4107
- * _.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user');
4168
+ * _.pluck(_.dropRightWhile(users, { 'age': 1, 'active': false }), 'user');
4108
4169
  * // => ['barney', 'fred']
4170
+ *
4171
+ * // using the "_.matchesProperty" callback shorthand
4172
+ * _.pluck(_.dropRightWhile(users, 'active', false), 'user');
4173
+ * // => ['barney']
4174
+ *
4175
+ * // using the "_.property" callback shorthand
4176
+ * _.pluck(_.dropRightWhile(users, 'active'), 'user');
4177
+ * // => ['barney', 'fred', 'pebbles']
4109
4178
  */
4110
4179
  function dropRightWhile(array, predicate, thisArg) {
4111
4180
  var length = array ? array.length : 0;
@@ -4125,13 +4194,16 @@
4125
4194
  * If a property name is provided for `predicate` the created "_.property"
4126
4195
  * style callback returns the property value of the given element.
4127
4196
  *
4197
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4198
+ * style callback returns `true` for elements that have a matching property
4199
+ * value, else `false`.
4200
+ *
4128
4201
  * If an object is provided for `predicate` the created "_.matches" style
4129
4202
  * callback returns `true` for elements that have the properties of the given
4130
4203
  * object, else `false`.
4131
4204
  *
4132
4205
  * @static
4133
4206
  * @memberOf _
4134
- * @type Function
4135
4207
  * @category Array
4136
4208
  * @param {Array} array The array to query.
4137
4209
  * @param {Function|Object|string} [predicate=_.identity] The function invoked
@@ -4144,18 +4216,22 @@
4144
4216
  * // => [3]
4145
4217
  *
4146
4218
  * var users = [
4147
- * { 'user': 'barney', 'status': 'busy', 'active': true },
4148
- * { 'user': 'fred', 'status': 'busy', 'active': false },
4149
- * { 'user': 'pebbles', 'status': 'away', 'active': true }
4219
+ * { 'user': 'barney', 'age': 36, 'active': false },
4220
+ * { 'user': 'fred', 'age': 40, 'active': false },
4221
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
4150
4222
  * ];
4151
4223
  *
4152
- * // using the "_.property" callback shorthand
4153
- * _.pluck(_.dropWhile(users, 'active'), 'user');
4224
+ * // using the "_.matches" callback shorthand
4225
+ * _.pluck(_.dropWhile(users, { 'age': 36, 'active': false }), 'user');
4154
4226
  * // => ['fred', 'pebbles']
4155
4227
  *
4156
- * // using the "_.matches" callback shorthand
4157
- * _.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user');
4228
+ * // using the "_.matchesProperty" callback shorthand
4229
+ * _.pluck(_.dropWhile(users, 'active', false), 'user');
4158
4230
  * // => ['pebbles']
4231
+ *
4232
+ * // using the "_.property" callback shorthand
4233
+ * _.pluck(_.dropWhile(users, 'active'), 'user');
4234
+ * // => ['barney', 'fred', 'pebbles']
4159
4235
  */
4160
4236
  function dropWhile(array, predicate, thisArg) {
4161
4237
  var length = array ? array.length : 0;
@@ -4168,6 +4244,33 @@
4168
4244
  return baseSlice(array, index);
4169
4245
  }
4170
4246
 
4247
+ /**
4248
+ * Fills elements of `array` with `value` from `start` up to, but not
4249
+ * including, `end`.
4250
+ *
4251
+ * **Note:** This method mutates `array`.
4252
+ *
4253
+ * @static
4254
+ * @memberOf _
4255
+ * @category Array
4256
+ * @param {Array} array The array to fill.
4257
+ * @param {*} value The value to fill `array` with.
4258
+ * @param {number} [start=0] The start position.
4259
+ * @param {number} [end=array.length] The end position.
4260
+ * @returns {Array} Returns `array`.
4261
+ */
4262
+ function fill(array, value, start, end) {
4263
+ var length = array ? array.length : 0;
4264
+ if (!length) {
4265
+ return [];
4266
+ }
4267
+ if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
4268
+ start = 0;
4269
+ end = length;
4270
+ }
4271
+ return baseFill(array, value, start, end);
4272
+ }
4273
+
4171
4274
  /**
4172
4275
  * This method is like `_.find` except that it returns the index of the first
4173
4276
  * element `predicate` returns truthy for, instead of the element itself.
@@ -4175,6 +4278,10 @@
4175
4278
  * If a property name is provided for `predicate` the created "_.property"
4176
4279
  * style callback returns the property value of the given element.
4177
4280
  *
4281
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4282
+ * style callback returns `true` for elements that have a matching property
4283
+ * value, else `false`.
4284
+ *
4178
4285
  * If an object is provided for `predicate` the created "_.matches" style
4179
4286
  * callback returns `true` for elements that have the properties of the given
4180
4287
  * object, else `false`.
@@ -4200,7 +4307,11 @@
4200
4307
  * // => 0
4201
4308
  *
4202
4309
  * // using the "_.matches" callback shorthand
4203
- * _.findIndex(users, { 'age': 1 });
4310
+ * _.findIndex(users, { 'age': 40, 'active': true });
4311
+ * // => 1
4312
+ *
4313
+ * // using the "_.matchesProperty" callback shorthand
4314
+ * _.findIndex(users, 'age', 1);
4204
4315
  * // => 2
4205
4316
  *
4206
4317
  * // using the "_.property" callback shorthand
@@ -4227,6 +4338,10 @@
4227
4338
  * If a property name is provided for `predicate` the created "_.property"
4228
4339
  * style callback returns the property value of the given element.
4229
4340
  *
4341
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4342
+ * style callback returns `true` for elements that have a matching property
4343
+ * value, else `false`.
4344
+ *
4230
4345
  * If an object is provided for `predicate` the created "_.matches" style
4231
4346
  * callback returns `true` for elements that have the properties of the given
4232
4347
  * object, else `false`.
@@ -4252,7 +4367,11 @@
4252
4367
  * // => 2
4253
4368
  *
4254
4369
  * // using the "_.matches" callback shorthand
4255
- * _.findLastIndex(users, { 'age': 40 });
4370
+ * _.findLastIndex(users, { 'age': 36, 'active': true });
4371
+ * // => 0
4372
+ *
4373
+ * // using the "_.matchesProperty" callback shorthand
4374
+ * _.findLastIndex(users, 'age', 40);
4256
4375
  * // => 1
4257
4376
  *
4258
4377
  * // using the "_.property" callback shorthand
@@ -4610,6 +4729,10 @@
4610
4729
  * If a property name is provided for `predicate` the created "_.property"
4611
4730
  * style callback returns the property value of the given element.
4612
4731
  *
4732
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4733
+ * style callback returns `true` for elements that have a matching property
4734
+ * value, else `false`.
4735
+ *
4613
4736
  * If an object is provided for `predicate` the created "_.matches" style
4614
4737
  * callback returns `true` for elements that have the properties of the given
4615
4738
  * object, else `false`.
@@ -4707,6 +4830,10 @@
4707
4830
  * If a property name is provided for `predicate` the created "_.property"
4708
4831
  * style callback returns the property value of the given element.
4709
4832
  *
4833
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4834
+ * style callback returns `true` for elements that have a matching property
4835
+ * value, else `false`.
4836
+ *
4710
4837
  * If an object is provided for `predicate` the created "_.matches" style
4711
4838
  * callback returns `true` for elements that have the properties of the given
4712
4839
  * object, else `false`.
@@ -4782,7 +4909,6 @@
4782
4909
  *
4783
4910
  * @static
4784
4911
  * @memberOf _
4785
- * @type Function
4786
4912
  * @category Array
4787
4913
  * @param {Array} array The array to query.
4788
4914
  * @param {number} [n=1] The number of elements to take.
@@ -4818,7 +4944,6 @@
4818
4944
  *
4819
4945
  * @static
4820
4946
  * @memberOf _
4821
- * @type Function
4822
4947
  * @category Array
4823
4948
  * @param {Array} array The array to query.
4824
4949
  * @param {number} [n=1] The number of elements to take.
@@ -4858,13 +4983,16 @@
4858
4983
  * If a property name is provided for `predicate` the created "_.property"
4859
4984
  * style callback returns the property value of the given element.
4860
4985
  *
4986
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
4987
+ * style callback returns `true` for elements that have a matching property
4988
+ * value, else `false`.
4989
+ *
4861
4990
  * If an object is provided for `predicate` the created "_.matches" style
4862
4991
  * callback returns `true` for elements that have the properties of the given
4863
4992
  * object, else `false`.
4864
4993
  *
4865
4994
  * @static
4866
4995
  * @memberOf _
4867
- * @type Function
4868
4996
  * @category Array
4869
4997
  * @param {Array} array The array to query.
4870
4998
  * @param {Function|Object|string} [predicate=_.identity] The function invoked
@@ -4877,18 +5005,22 @@
4877
5005
  * // => [2, 3]
4878
5006
  *
4879
5007
  * var users = [
4880
- * { 'user': 'barney', 'status': 'busy', 'active': false },
4881
- * { 'user': 'fred', 'status': 'busy', 'active': true },
4882
- * { 'user': 'pebbles', 'status': 'away', 'active': true }
5008
+ * { 'user': 'barney', 'age': 36, 'active': true },
5009
+ * { 'user': 'fred', 'age': 40, 'active': false },
5010
+ * { 'user': 'pebbles', 'age': 1, 'active': false }
4883
5011
  * ];
4884
5012
  *
4885
- * // using the "_.property" callback shorthand
4886
- * _.pluck(_.takeRightWhile(users, 'active'), 'user');
4887
- * // => ['fred', 'pebbles']
4888
- *
4889
5013
  * // using the "_.matches" callback shorthand
4890
- * _.pluck(_.takeRightWhile(users, { 'status': 'away' }), 'user');
5014
+ * _.pluck(_.takeRightWhile(users, { 'age': 1, 'active': true }), 'user');
4891
5015
  * // => ['pebbles']
5016
+ *
5017
+ * // using the "_.matchesProperty" callback shorthand
5018
+ * _.pluck(_.takeRightWhile(users, 'active', false), 'user');
5019
+ * // => ['fred', 'pebbles']
5020
+ *
5021
+ * // using the "_.property" callback shorthand
5022
+ * _.pluck(_.takeRightWhile(users, 'active'), 'user');
5023
+ * // => []
4892
5024
  */
4893
5025
  function takeRightWhile(array, predicate, thisArg) {
4894
5026
  var length = array ? array.length : 0;
@@ -4908,13 +5040,16 @@
4908
5040
  * If a property name is provided for `predicate` the created "_.property"
4909
5041
  * style callback returns the property value of the given element.
4910
5042
  *
5043
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5044
+ * style callback returns `true` for elements that have a matching property
5045
+ * value, else `false`.
5046
+ *
4911
5047
  * If an object is provided for `predicate` the created "_.matches" style
4912
5048
  * callback returns `true` for elements that have the properties of the given
4913
5049
  * object, else `false`.
4914
5050
  *
4915
5051
  * @static
4916
5052
  * @memberOf _
4917
- * @type Function
4918
5053
  * @category Array
4919
5054
  * @param {Array} array The array to query.
4920
5055
  * @param {Function|Object|string} [predicate=_.identity] The function invoked
@@ -4927,18 +5062,22 @@
4927
5062
  * // => [1, 2]
4928
5063
  *
4929
5064
  * var users = [
4930
- * { 'user': 'barney', 'status': 'busy', 'active': true },
4931
- * { 'user': 'fred', 'status': 'busy', 'active': false },
4932
- * { 'user': 'pebbles', 'status': 'away', 'active': true }
5065
+ * { 'user': 'barney', 'age': 36, 'active': false },
5066
+ * { 'user': 'fred', 'age': 40, 'active': false },
5067
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
4933
5068
  * ];
4934
5069
  *
4935
- * // using the "_.property" callback shorthand
4936
- * _.pluck(_.takeWhile(users, 'active'), 'user');
5070
+ * // using the "_.matches" callback shorthand
5071
+ * _.pluck(_.takeWhile(users, { 'age': 36, 'active': true }), 'user');
4937
5072
  * // => ['barney']
4938
5073
  *
4939
- * // using the "_.matches" callback shorthand
4940
- * _.pluck(_.takeWhile(users, { 'status': 'busy' }), 'user');
5074
+ * // using the "_.matchesProperty" callback shorthand
5075
+ * _.pluck(_.takeWhile(users, 'active', false), 'user');
4941
5076
  * // => ['barney', 'fred']
5077
+ *
5078
+ * // using the "_.property" callback shorthand
5079
+ * _.pluck(_.takeWhile(users, 'active'), 'user');
5080
+ * // => []
4942
5081
  */
4943
5082
  function takeWhile(array, predicate, thisArg) {
4944
5083
  var length = array ? array.length : 0;
@@ -4985,6 +5124,10 @@
4985
5124
  * If a property name is provided for `predicate` the created "_.property"
4986
5125
  * style callback returns the property value of the given element.
4987
5126
  *
5127
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5128
+ * style callback returns `true` for elements that have a matching property
5129
+ * value, else `false`.
5130
+ *
4988
5131
  * If an object is provided for `predicate` the created "_.matches" style
4989
5132
  * callback returns `true` for elements that have the properties of the given
4990
5133
  * object, else `false`.
@@ -5199,7 +5342,7 @@
5199
5342
  * @memberOf _
5200
5343
  * @category Chain
5201
5344
  * @param {*} value The value to wrap.
5202
- * @returns {Object} Returns the new `lodash` object.
5345
+ * @returns {Object} Returns the new `lodash` wrapper instance.
5203
5346
  * @example
5204
5347
  *
5205
5348
  * var users = [
@@ -5275,7 +5418,7 @@
5275
5418
  * @name chain
5276
5419
  * @memberOf _
5277
5420
  * @category Chain
5278
- * @returns {*} Returns the `lodash` object.
5421
+ * @returns {Object} Returns the new `lodash` wrapper instance.
5279
5422
  * @example
5280
5423
  *
5281
5424
  * var users = [
@@ -5298,6 +5441,76 @@
5298
5441
  return chain(this);
5299
5442
  }
5300
5443
 
5444
+ /**
5445
+ * Executes the chained sequence and returns the wrapped result.
5446
+ *
5447
+ * @name commit
5448
+ * @memberOf _
5449
+ * @category Chain
5450
+ * @returns {Object} Returns the new `lodash` wrapper instance.
5451
+ * @example
5452
+ *
5453
+ * var array = [1, 2];
5454
+ * var wrapper = _(array).push(3);
5455
+ *
5456
+ * console.log(array);
5457
+ * // => [1, 2]
5458
+ *
5459
+ * wrapper = wrapper.commit();
5460
+ * console.log(array);
5461
+ * // => [1, 2, 3]
5462
+ *
5463
+ * wrapper.last();
5464
+ * // => 3
5465
+ *
5466
+ * console.log(array);
5467
+ * // => [1, 2, 3]
5468
+ */
5469
+ function wrapperCommit() {
5470
+ return new LodashWrapper(this.value(), this.__chain__);
5471
+ }
5472
+
5473
+ /**
5474
+ * Creates a clone of the chained sequence planting `value` as the wrapped value.
5475
+ *
5476
+ * @name plant
5477
+ * @memberOf _
5478
+ * @category Chain
5479
+ * @returns {Object} Returns the new `lodash` wrapper instance.
5480
+ * @example
5481
+ *
5482
+ * var array = [1, 2];
5483
+ * var wrapper = _(array).map(function(value) {
5484
+ * return Math.pow(value, 2);
5485
+ * });
5486
+ *
5487
+ * var other = [3, 4];
5488
+ * var otherWrapper = wrapper.plant(other);
5489
+ *
5490
+ * otherWrapper.value();
5491
+ * // => [9, 16]
5492
+ *
5493
+ * wrapper.value();
5494
+ * // => [1, 4]
5495
+ */
5496
+ function wrapperPlant(value) {
5497
+ var result,
5498
+ parent = this;
5499
+
5500
+ while (parent instanceof LodashWrapper) {
5501
+ var clone = wrapperClone(parent);
5502
+ if (result) {
5503
+ previous.__wrapped__ = clone;
5504
+ } else {
5505
+ result = clone;
5506
+ }
5507
+ var previous = clone;
5508
+ parent = parent.__wrapped__;
5509
+ }
5510
+ previous.__wrapped__ = value;
5511
+ return result;
5512
+ }
5513
+
5301
5514
  /**
5302
5515
  * Reverses the wrapped array so the first element becomes the last, the
5303
5516
  * second element becomes the second to last, and so on.
@@ -5307,7 +5520,7 @@
5307
5520
  * @name reverse
5308
5521
  * @memberOf _
5309
5522
  * @category Chain
5310
- * @returns {Object} Returns the new reversed `lodash` object.
5523
+ * @returns {Object} Returns the new reversed `lodash` wrapper instance.
5311
5524
  * @example
5312
5525
  *
5313
5526
  * var array = [1, 2, 3];
@@ -5324,7 +5537,7 @@
5324
5537
  if (this.__actions__.length) {
5325
5538
  value = new LazyWrapper(this);
5326
5539
  }
5327
- return new LodashWrapper(value.reverse());
5540
+ return new LodashWrapper(value.reverse(), this.__chain__);
5328
5541
  }
5329
5542
  return this.thru(function(value) {
5330
5543
  return value.reverse();
@@ -5352,7 +5565,7 @@
5352
5565
  *
5353
5566
  * @name value
5354
5567
  * @memberOf _
5355
- * @alias toJSON, valueOf
5568
+ * @alias run, toJSON, valueOf
5356
5569
  * @category Chain
5357
5570
  * @returns {*} Returns the resolved unwrapped value.
5358
5571
  * @example
@@ -5455,6 +5668,10 @@
5455
5668
  * If a property name is provided for `predicate` the created "_.property"
5456
5669
  * style callback returns the property value of the given element.
5457
5670
  *
5671
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5672
+ * style callback returns `true` for elements that have a matching property
5673
+ * value, else `false`.
5674
+ *
5458
5675
  * If an object is provided for `predicate` the created "_.matches" style
5459
5676
  * callback returns `true` for elements that have the properties of the given
5460
5677
  * object, else `false`.
@@ -5491,6 +5708,10 @@
5491
5708
  * If a property name is provided for `predicate` the created "_.property"
5492
5709
  * style callback returns the property value of the given element.
5493
5710
  *
5711
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5712
+ * style callback returns `true` for elements that have a matching property
5713
+ * value, else `false`.
5714
+ *
5494
5715
  * If an object is provided for `predicate` the created "_.matches" style
5495
5716
  * callback returns `true` for elements that have the properties of the given
5496
5717
  * object, else `false`.
@@ -5512,16 +5733,20 @@
5512
5733
  * // => false
5513
5734
  *
5514
5735
  * var users = [
5515
- * { 'user': 'barney', 'age': 36 },
5516
- * { 'user': 'fred', 'age': 40 }
5736
+ * { 'user': 'barney', 'age': 36, 'active': false },
5737
+ * { 'user': 'fred', 'age': 40, 'active': false }
5517
5738
  * ];
5518
5739
  *
5519
- * // using the "_.property" callback shorthand
5520
- * _.every(users, 'age');
5740
+ * // using the "_.matches" callback shorthand
5741
+ * _.every(users, { 'age': 36, 'active': false });
5742
+ * // => false
5743
+ *
5744
+ * // using the "_.matchesProperty" callback shorthand
5745
+ * _.every(users, 'active', false);
5521
5746
  * // => true
5522
5747
  *
5523
- * // using the "_.matches" callback shorthand
5524
- * _.every(users, { 'age': 36 });
5748
+ * // using the "_.property" callback shorthand
5749
+ * _.every(users, 'active');
5525
5750
  * // => false
5526
5751
  */
5527
5752
  function every(collection, predicate, thisArg) {
@@ -5540,6 +5765,10 @@
5540
5765
  * If a property name is provided for `predicate` the created "_.property"
5541
5766
  * style callback returns the property value of the given element.
5542
5767
  *
5768
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5769
+ * style callback returns `true` for elements that have a matching property
5770
+ * value, else `false`.
5771
+ *
5543
5772
  * If an object is provided for `predicate` the created "_.matches" style
5544
5773
  * callback returns `true` for elements that have the properties of the given
5545
5774
  * object, else `false`.
@@ -5560,16 +5789,20 @@
5560
5789
  * // => [2, 4]
5561
5790
  *
5562
5791
  * var users = [
5563
- * { 'user': 'barney', 'age': 36, 'active': false },
5564
- * { 'user': 'fred', 'age': 40, 'active': true }
5792
+ * { 'user': 'barney', 'age': 36, 'active': true },
5793
+ * { 'user': 'fred', 'age': 40, 'active': false }
5565
5794
  * ];
5566
5795
  *
5567
- * // using the "_.property" callback shorthand
5568
- * _.pluck(_.filter(users, 'active'), 'user');
5796
+ * // using the "_.matches" callback shorthand
5797
+ * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
5798
+ * // => ['barney']
5799
+ *
5800
+ * // using the "_.matchesProperty" callback shorthand
5801
+ * _.pluck(_.filter(users, 'active', false), 'user');
5569
5802
  * // => ['fred']
5570
5803
  *
5571
- * // using the "_.matches" callback shorthand
5572
- * _.pluck(_.filter(users, { 'age': 36 }), 'user');
5804
+ * // using the "_.property" callback shorthand
5805
+ * _.pluck(_.filter(users, 'active'), 'user');
5573
5806
  * // => ['barney']
5574
5807
  */
5575
5808
  function filter(collection, predicate, thisArg) {
@@ -5586,6 +5819,10 @@
5586
5819
  * If a property name is provided for `predicate` the created "_.property"
5587
5820
  * style callback returns the property value of the given element.
5588
5821
  *
5822
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5823
+ * style callback returns `true` for elements that have a matching property
5824
+ * value, else `false`.
5825
+ *
5589
5826
  * If an object is provided for `predicate` the created "_.matches" style
5590
5827
  * callback returns `true` for elements that have the properties of the given
5591
5828
  * object, else `false`.
@@ -5603,21 +5840,25 @@
5603
5840
  * @example
5604
5841
  *
5605
5842
  * var users = [
5606
- * { 'user': 'barney', 'age': 36, 'active': false },
5607
- * { 'user': 'fred', 'age': 40, 'active': true },
5608
- * { 'user': 'pebbles', 'age': 1, 'active': false }
5843
+ * { 'user': 'barney', 'age': 36, 'active': true },
5844
+ * { 'user': 'fred', 'age': 40, 'active': false },
5845
+ * { 'user': 'pebbles', 'age': 1, 'active': true }
5609
5846
  * ];
5610
5847
  *
5611
5848
  * _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user');
5612
5849
  * // => 'barney'
5613
5850
  *
5614
5851
  * // using the "_.matches" callback shorthand
5615
- * _.result(_.find(users, { 'age': 1 }), 'user');
5852
+ * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
5616
5853
  * // => 'pebbles'
5617
5854
  *
5855
+ * // using the "_.matchesProperty" callback shorthand
5856
+ * _.result(_.find(users, 'active', false), 'user');
5857
+ * // => 'fred'
5858
+ *
5618
5859
  * // using the "_.property" callback shorthand
5619
5860
  * _.result(_.find(users, 'active'), 'user');
5620
- * // => 'fred'
5861
+ * // => 'barney'
5621
5862
  */
5622
5863
  function find(collection, predicate, thisArg) {
5623
5864
  if (isArray(collection)) {
@@ -5656,6 +5897,11 @@
5656
5897
  * source object, returning the first element that has equivalent property
5657
5898
  * values.
5658
5899
  *
5900
+ * **Note:** This method supports comparing arrays, booleans, `Date` objects,
5901
+ * numbers, `Object` objects, regexes, and strings. Objects are compared by
5902
+ * their own, not inherited, enumerable properties. For comparing a single
5903
+ * own or inherited property value see `_.matchesProperty`.
5904
+ *
5659
5905
  * @static
5660
5906
  * @memberOf _
5661
5907
  * @category Collection
@@ -5665,14 +5911,14 @@
5665
5911
  * @example
5666
5912
  *
5667
5913
  * var users = [
5668
- * { 'user': 'barney', 'age': 36, 'status': 'busy' },
5669
- * { 'user': 'fred', 'age': 40, 'status': 'busy' }
5914
+ * { 'user': 'barney', 'age': 36, 'active': true },
5915
+ * { 'user': 'fred', 'age': 40, 'active': false }
5670
5916
  * ];
5671
5917
  *
5672
- * _.result(_.findWhere(users, { 'status': 'busy' }), 'user');
5918
+ * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');
5673
5919
  * // => 'barney'
5674
5920
  *
5675
- * _.result(_.findWhere(users, { 'age': 40 }), 'user');
5921
+ * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');
5676
5922
  * // => 'fred'
5677
5923
  */
5678
5924
  function findWhere(collection, source) {
@@ -5744,6 +5990,10 @@
5744
5990
  * If a property name is provided for `predicate` the created "_.property"
5745
5991
  * style callback returns the property value of the given element.
5746
5992
  *
5993
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
5994
+ * style callback returns `true` for elements that have a matching property
5995
+ * value, else `false`.
5996
+ *
5747
5997
  * If an object is provided for `predicate` the created "_.matches" style
5748
5998
  * callback returns `true` for elements that have the properties of the given
5749
5999
  * object, else `false`.
@@ -5787,6 +6037,10 @@
5787
6037
  * If a property name is provided for `predicate` the created "_.property"
5788
6038
  * style callback returns the property value of the given element.
5789
6039
  *
6040
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6041
+ * style callback returns `true` for elements that have a matching property
6042
+ * value, else `false`.
6043
+ *
5790
6044
  * If an object is provided for `predicate` the created "_.matches" style
5791
6045
  * callback returns `true` for elements that have the properties of the given
5792
6046
  * object, else `false`.
@@ -5854,10 +6108,23 @@
5854
6108
  * If a property name is provided for `predicate` the created "_.property"
5855
6109
  * style callback returns the property value of the given element.
5856
6110
  *
6111
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6112
+ * style callback returns `true` for elements that have a matching property
6113
+ * value, else `false`.
6114
+ *
5857
6115
  * If an object is provided for `predicate` the created "_.matches" style
5858
6116
  * callback returns `true` for elements that have the properties of the given
5859
6117
  * object, else `false`.
5860
6118
  *
6119
+ * Many lodash methods are guarded to work as interatees for methods like
6120
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
6121
+ *
6122
+ * The guarded methods are:
6123
+ * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
6124
+ * `dropRight`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, `slice`,
6125
+ * `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, `trimRight`,
6126
+ * `trunc`, `random`, `range`, `sample`, `uniq`, and `words`
6127
+ *
5861
6128
  * @static
5862
6129
  * @memberOf _
5863
6130
  * @alias collect
@@ -5901,6 +6168,10 @@
5901
6168
  * If a property name is provided for `predicate` the created "_.property"
5902
6169
  * style callback returns the property value of the given element.
5903
6170
  *
6171
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6172
+ * style callback returns `true` for elements that have a matching property
6173
+ * value, else `false`.
6174
+ *
5904
6175
  * If an object is provided for `predicate` the created "_.matches" style
5905
6176
  * callback returns `true` for elements that have the properties of the given
5906
6177
  * object, else `false`.
@@ -5946,6 +6217,10 @@
5946
6217
  * If a property name is provided for `predicate` the created "_.property"
5947
6218
  * style callback returns the property value of the given element.
5948
6219
  *
6220
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6221
+ * style callback returns `true` for elements that have a matching property
6222
+ * value, else `false`.
6223
+ *
5949
6224
  * If an object is provided for `predicate` the created "_.matches" style
5950
6225
  * callback returns `true` for elements that have the properties of the given
5951
6226
  * object, else `false`.
@@ -5990,6 +6265,10 @@
5990
6265
  * If a property name is provided for `predicate` the created "_.property"
5991
6266
  * style callback returns the property value of the given element.
5992
6267
  *
6268
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6269
+ * style callback returns `true` for elements that have a matching property
6270
+ * value, else `false`.
6271
+ *
5993
6272
  * If an object is provided for `predicate` the created "_.matches" style
5994
6273
  * callback returns `true` for elements that have the properties of the given
5995
6274
  * object, else `false`.
@@ -6017,12 +6296,18 @@
6017
6296
  * { 'user': 'pebbles', 'age': 1, 'active': false }
6018
6297
  * ];
6019
6298
  *
6299
+ * var mapper = function(array) { return _.pluck(array, 'user'); };
6300
+ *
6020
6301
  * // using the "_.matches" callback shorthand
6021
- * _.map(_.partition(users, { 'age': 1 }), function(array) { return _.pluck(array, 'user'); });
6302
+ * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);
6022
6303
  * // => [['pebbles'], ['barney', 'fred']]
6023
6304
  *
6305
+ * // using the "_.matchesProperty" callback shorthand
6306
+ * _.map(_.partition(users, 'active', false), mapper);
6307
+ * // => [['barney', 'pebbles'], ['fred']]
6308
+ *
6024
6309
  * // using the "_.property" callback shorthand
6025
- * _.map(_.partition(users, 'active'), function(array) { return _.pluck(array, 'user'); });
6310
+ * _.map(_.partition(users, 'active'), mapper);
6026
6311
  * // => [['fred'], ['barney', 'pebbles']]
6027
6312
  */
6028
6313
  var partition = createAggregator(function(result, value, key) {
@@ -6053,7 +6338,7 @@
6053
6338
  * // => [36, 40] (iteration order is not guaranteed)
6054
6339
  */
6055
6340
  function pluck(collection, key) {
6056
- return map(collection, baseProperty(key + ''));
6341
+ return map(collection, baseProperty(key));
6057
6342
  }
6058
6343
 
6059
6344
  /**
@@ -6064,6 +6349,12 @@
6064
6349
  * value. The `iteratee` is bound to `thisArg`and invoked with four arguments;
6065
6350
  * (accumulator, value, index|key, collection).
6066
6351
  *
6352
+ * Many lodash methods are guarded to work as interatees for methods like
6353
+ * `_.reduce`, `_.reduceRight`, and `_.transform`.
6354
+ *
6355
+ * The guarded methods are:
6356
+ * `assign`, `defaults`, `merge`, and `sortAllBy`
6357
+ *
6067
6358
  * @static
6068
6359
  * @memberOf _
6069
6360
  * @alias foldl, inject
@@ -6120,6 +6411,10 @@
6120
6411
  * If a property name is provided for `predicate` the created "_.property"
6121
6412
  * style callback returns the property value of the given element.
6122
6413
  *
6414
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6415
+ * style callback returns `true` for elements that have a matching property
6416
+ * value, else `false`.
6417
+ *
6123
6418
  * If an object is provided for `predicate` the created "_.matches" style
6124
6419
  * callback returns `true` for elements that have the properties of the given
6125
6420
  * object, else `false`.
@@ -6143,13 +6438,17 @@
6143
6438
  * { 'user': 'fred', 'age': 40, 'active': true }
6144
6439
  * ];
6145
6440
  *
6146
- * // using the "_.property" callback shorthand
6147
- * _.pluck(_.reject(users, 'active'), 'user');
6441
+ * // using the "_.matches" callback shorthand
6442
+ * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
6148
6443
  * // => ['barney']
6149
6444
  *
6150
- * // using the "_.matches" callback shorthand
6151
- * _.pluck(_.reject(users, { 'age': 36 }), 'user');
6445
+ * // using the "_.matchesProperty" callback shorthand
6446
+ * _.pluck(_.reject(users, 'active', false), 'user');
6152
6447
  * // => ['fred']
6448
+ *
6449
+ * // using the "_.property" callback shorthand
6450
+ * _.pluck(_.reject(users, 'active'), 'user');
6451
+ * // => ['barney']
6153
6452
  */
6154
6453
  function reject(collection, predicate, thisArg) {
6155
6454
  var func = isArray(collection) ? arrayFilter : baseFilter;
@@ -6254,6 +6553,10 @@
6254
6553
  * If a property name is provided for `predicate` the created "_.property"
6255
6554
  * style callback returns the property value of the given element.
6256
6555
  *
6556
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6557
+ * style callback returns `true` for elements that have a matching property
6558
+ * value, else `false`.
6559
+ *
6257
6560
  * If an object is provided for `predicate` the created "_.matches" style
6258
6561
  * callback returns `true` for elements that have the properties of the given
6259
6562
  * object, else `false`.
@@ -6279,13 +6582,17 @@
6279
6582
  * { 'user': 'fred', 'age': 40, 'active': true }
6280
6583
  * ];
6281
6584
  *
6585
+ * // using the "_.matches" callback shorthand
6586
+ * _.some(users, { 'age': 1, 'active': true });
6587
+ * // => false
6588
+ *
6589
+ * // using the "_.matchesProperty" callback shorthand
6590
+ * _.some(users, 'active', false);
6591
+ * // => true
6592
+ *
6282
6593
  * // using the "_.property" callback shorthand
6283
6594
  * _.some(users, 'active');
6284
6595
  * // => true
6285
- *
6286
- * // using the "_.matches" callback shorthand
6287
- * _.some(users, { 'age': 1 });
6288
- * // => false
6289
6596
  */
6290
6597
  function some(collection, predicate, thisArg) {
6291
6598
  var func = isArray(collection) ? arraySome : baseSome;
@@ -6305,6 +6612,10 @@
6305
6612
  * If a property name is provided for `predicate` the created "_.property"
6306
6613
  * style callback returns the property value of the given element.
6307
6614
  *
6615
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
6616
+ * style callback returns `true` for elements that have a matching property
6617
+ * value, else `false`.
6618
+ *
6308
6619
  * If an object is provided for `predicate` the created "_.matches" style
6309
6620
  * callback returns `true` for elements that have the properties of the given
6310
6621
  * object, else `false`.
@@ -6384,7 +6695,7 @@
6384
6695
  props = baseFlatten(args, false, false, 1),
6385
6696
  result = isLength(length) ? Array(length) : [];
6386
6697
 
6387
- baseEach(collection, function(value, key, collection) {
6698
+ baseEach(collection, function(value) {
6388
6699
  var length = props.length,
6389
6700
  criteria = Array(length);
6390
6701
 
@@ -6401,6 +6712,11 @@
6401
6712
  * source object, returning an array of all elements that have equivalent
6402
6713
  * property values.
6403
6714
  *
6715
+ * **Note:** This method supports comparing arrays, booleans, `Date` objects,
6716
+ * numbers, `Object` objects, regexes, and strings. Objects are compared by
6717
+ * their own, not inherited, enumerable properties. For comparing a single
6718
+ * own or inherited property value see `_.matchesProperty`.
6719
+ *
6404
6720
  * @static
6405
6721
  * @memberOf _
6406
6722
  * @category Collection
@@ -6410,18 +6726,15 @@
6410
6726
  * @example
6411
6727
  *
6412
6728
  * var users = [
6413
- * { 'user': 'barney', 'age': 36, 'status': 'busy', 'pets': ['hoppy'] },
6414
- * { 'user': 'fred', 'age': 40, 'status': 'busy', 'pets': ['baby puss', 'dino'] }
6729
+ * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
6730
+ * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
6415
6731
  * ];
6416
6732
  *
6417
- * _.pluck(_.where(users, { 'age': 36 }), 'user');
6733
+ * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
6418
6734
  * // => ['barney']
6419
6735
  *
6420
6736
  * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');
6421
6737
  * // => ['fred']
6422
- *
6423
- * _.pluck(_.where(users, { 'status': 'busy' }), 'user');
6424
- * // => ['barney', 'fred']
6425
6738
  */
6426
6739
  function where(collection, source) {
6427
6740
  return filter(collection, baseMatches(source));
@@ -6471,8 +6784,8 @@
6471
6784
  * // => logs 'done saving!' after the two async saves have completed
6472
6785
  */
6473
6786
  function after(n, func) {
6474
- if (!isFunction(func)) {
6475
- if (isFunction(n)) {
6787
+ if (typeof func != 'function') {
6788
+ if (typeof n == 'function') {
6476
6789
  var temp = n;
6477
6790
  n = func;
6478
6791
  func = temp;
@@ -6530,8 +6843,8 @@
6530
6843
  */
6531
6844
  function before(n, func) {
6532
6845
  var result;
6533
- if (!isFunction(func)) {
6534
- if (isFunction(n)) {
6846
+ if (typeof func != 'function') {
6847
+ if (typeof n == 'function') {
6535
6848
  var temp = n;
6536
6849
  n = func;
6537
6850
  func = temp;
@@ -6853,7 +7166,7 @@
6853
7166
  maxWait = false,
6854
7167
  trailing = true;
6855
7168
 
6856
- if (!isFunction(func)) {
7169
+ if (typeof func != 'function') {
6857
7170
  throw new TypeError(FUNC_ERROR_TEXT);
6858
7171
  }
6859
7172
  wait = wait < 0 ? 0 : wait;
@@ -7023,7 +7336,7 @@
7023
7336
  length = funcs.length;
7024
7337
 
7025
7338
  if (!length) {
7026
- return function() {};
7339
+ return function() { return arguments[0]; };
7027
7340
  }
7028
7341
  if (!arrayEvery(funcs, isFunction)) {
7029
7342
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -7068,7 +7381,7 @@
7068
7381
  fromIndex = funcs.length - 1;
7069
7382
 
7070
7383
  if (fromIndex < 0) {
7071
- return function() {};
7384
+ return function() { return arguments[0]; };
7072
7385
  }
7073
7386
  if (!arrayEvery(funcs, isFunction)) {
7074
7387
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -7138,7 +7451,7 @@
7138
7451
  * // => { 'user': 'barney' }
7139
7452
  */
7140
7453
  function memoize(func, resolver) {
7141
- if (!isFunction(func) || (resolver && !isFunction(resolver))) {
7454
+ if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
7142
7455
  throw new TypeError(FUNC_ERROR_TEXT);
7143
7456
  }
7144
7457
  var memoized = function() {
@@ -7176,7 +7489,7 @@
7176
7489
  * // => [1, 3, 5]
7177
7490
  */
7178
7491
  function negate(predicate) {
7179
- if (!isFunction(predicate)) {
7492
+ if (typeof predicate != 'function') {
7180
7493
  throw new TypeError(FUNC_ERROR_TEXT);
7181
7494
  }
7182
7495
  return function() {
@@ -7191,7 +7504,6 @@
7191
7504
  *
7192
7505
  * @static
7193
7506
  * @memberOf _
7194
- * @type Function
7195
7507
  * @category Function
7196
7508
  * @param {Function} func The function to restrict.
7197
7509
  * @returns {Function} Returns the new restricted function.
@@ -7314,6 +7626,45 @@
7314
7626
  return createWrapper(func, REARG_FLAG, null, null, null, indexes);
7315
7627
  }
7316
7628
 
7629
+ /**
7630
+ * Creates a function that invokes `func` with the `this` binding of the
7631
+ * created function and the array of arguments provided to the created
7632
+ * function much like [Function#apply](http://es5.github.io/#x15.3.4.3).
7633
+ *
7634
+ * @static
7635
+ * @memberOf _
7636
+ * @category Function
7637
+ * @param {Function} func The function to spread arguments over.
7638
+ * @returns {*} Returns the new function.
7639
+ * @example
7640
+ *
7641
+ * var spread = _.spread(function(who, what) {
7642
+ * return who + ' says ' + what;
7643
+ * });
7644
+ *
7645
+ * spread(['Fred', 'hello']);
7646
+ * // => 'Fred says hello'
7647
+ *
7648
+ * // with a Promise
7649
+ * var numbers = Promise.all([
7650
+ * Promise.resolve(40),
7651
+ * Promise.resolve(36)
7652
+ * ]);
7653
+ *
7654
+ * numbers.then(_.spread(function(x, y) {
7655
+ * return x + y;
7656
+ * }));
7657
+ * // => a Promise of 76
7658
+ */
7659
+ function spread(func) {
7660
+ if (typeof func != 'function') {
7661
+ throw new TypeError(FUNC_ERROR_TEXT);
7662
+ }
7663
+ return function(array) {
7664
+ return func.apply(this, array);
7665
+ };
7666
+ }
7667
+
7317
7668
  /**
7318
7669
  * Creates a function that only invokes `func` at most once per every `wait`
7319
7670
  * milliseconds. The created function comes with a `cancel` method to cancel
@@ -7356,7 +7707,7 @@
7356
7707
  var leading = true,
7357
7708
  trailing = true;
7358
7709
 
7359
- if (!isFunction(func)) {
7710
+ if (typeof func != 'function') {
7360
7711
  throw new TypeError(FUNC_ERROR_TEXT);
7361
7712
  }
7362
7713
  if (options === false) {
@@ -7662,7 +8013,8 @@
7662
8013
  * arguments; (value, other [, index|key]).
7663
8014
  *
7664
8015
  * **Note:** This method supports comparing arrays, booleans, `Date` objects,
7665
- * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes
8016
+ * numbers, `Object` objects, regexes, and strings. Objects are compared by
8017
+ * their own, not inherited, enumerable properties. Functions and DOM nodes
7666
8018
  * are **not** supported. Provide a customizer function to extend support
7667
8019
  * for comparing other values.
7668
8020
  *
@@ -7832,7 +8184,7 @@
7832
8184
  * @static
7833
8185
  * @memberOf _
7834
8186
  * @category Lang
7835
- * @param {Object} source The object to inspect.
8187
+ * @param {Object} object The object to inspect.
7836
8188
  * @param {Object} source The object of property values to match.
7837
8189
  * @param {Function} [customizer] The function to customize comparing values.
7838
8190
  * @param {*} [thisArg] The `this` binding of `customizer`.
@@ -8261,6 +8613,10 @@
8261
8613
  * If a property name is provided for `predicate` the created "_.property"
8262
8614
  * style callback returns the property value of the given element.
8263
8615
  *
8616
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
8617
+ * style callback returns `true` for elements that have a matching property
8618
+ * value, else `false`.
8619
+ *
8264
8620
  * If an object is provided for `predicate` the created "_.matches" style
8265
8621
  * callback returns `true` for elements that have the properties of the given
8266
8622
  * object, else `false`.
@@ -8286,9 +8642,13 @@
8286
8642
  * // => 'barney' (iteration order is not guaranteed)
8287
8643
  *
8288
8644
  * // using the "_.matches" callback shorthand
8289
- * _.findKey(users, { 'age': 1 });
8645
+ * _.findKey(users, { 'age': 1, 'active': true });
8290
8646
  * // => 'pebbles'
8291
8647
  *
8648
+ * // using the "_.matchesProperty" callback shorthand
8649
+ * _.findKey(users, 'active', false);
8650
+ * // => 'fred'
8651
+ *
8292
8652
  * // using the "_.property" callback shorthand
8293
8653
  * _.findKey(users, 'active');
8294
8654
  * // => 'barney'
@@ -8305,6 +8665,10 @@
8305
8665
  * If a property name is provided for `predicate` the created "_.property"
8306
8666
  * style callback returns the property value of the given element.
8307
8667
  *
8668
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
8669
+ * style callback returns `true` for elements that have a matching property
8670
+ * value, else `false`.
8671
+ *
8308
8672
  * If an object is provided for `predicate` the created "_.matches" style
8309
8673
  * callback returns `true` for elements that have the properties of the given
8310
8674
  * object, else `false`.
@@ -8330,9 +8694,13 @@
8330
8694
  * // => returns `pebbles` assuming `_.findKey` returns `barney`
8331
8695
  *
8332
8696
  * // using the "_.matches" callback shorthand
8333
- * _.findLastKey(users, { 'age': 36 });
8697
+ * _.findLastKey(users, { 'age': 36, 'active': true });
8334
8698
  * // => 'barney'
8335
8699
  *
8700
+ * // using the "_.matchesProperty" callback shorthand
8701
+ * _.findLastKey(users, 'active', false);
8702
+ * // => 'fred'
8703
+ *
8336
8704
  * // using the "_.property" callback shorthand
8337
8705
  * _.findLastKey(users, 'active');
8338
8706
  * // => 'pebbles'
@@ -8620,7 +8988,7 @@
8620
8988
 
8621
8989
  var Ctor = object.constructor,
8622
8990
  index = -1,
8623
- isProto = typeof Ctor == 'function' && Ctor.prototype == object,
8991
+ isProto = typeof Ctor == 'function' && Ctor.prototype === object,
8624
8992
  result = Array(length),
8625
8993
  skipIndexes = length > 0;
8626
8994
 
@@ -8645,6 +9013,10 @@
8645
9013
  * If a property name is provided for `iteratee` the created "_.property"
8646
9014
  * style callback returns the property value of the given element.
8647
9015
  *
9016
+ * If value is also provided for `thisArg` the created "_.matchesProperty"
9017
+ * style callback returns `true` for elements that have a matching property
9018
+ * value, else `false`.
9019
+ *
8648
9020
  * If an object is provided for `iteratee` the created "_.matches" style
8649
9021
  * callback returns `true` for elements that have the properties of the given
8650
9022
  * object, else `false`.
@@ -8913,7 +9285,7 @@
8913
9285
  if (isArr) {
8914
9286
  accumulator = isArray(object) ? new Ctor : [];
8915
9287
  } else {
8916
- accumulator = baseCreate(typeof Ctor == 'function' && Ctor.prototype);
9288
+ accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype);
8917
9289
  }
8918
9290
  } else {
8919
9291
  accumulator = {};
@@ -9743,7 +10115,7 @@
9743
10115
  return string;
9744
10116
  }
9745
10117
  if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
9746
- return string.slice(trimmedLeftIndex(string))
10118
+ return string.slice(trimmedLeftIndex(string));
9747
10119
  }
9748
10120
  return string.slice(charsLeftIndex(string, (chars + '')));
9749
10121
  }
@@ -9773,7 +10145,7 @@
9773
10145
  return string;
9774
10146
  }
9775
10147
  if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
9776
- return string.slice(0, trimmedRightIndex(string) + 1)
10148
+ return string.slice(0, trimmedRightIndex(string) + 1);
9777
10149
  }
9778
10150
  return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
9779
10151
  }
@@ -9916,8 +10288,8 @@
9916
10288
  /*------------------------------------------------------------------------*/
9917
10289
 
9918
10290
  /**
9919
- * Attempts to invoke `func`, returning either the result or the caught
9920
- * error object.
10291
+ * Attempts to invoke `func`, returning either the result or the caught error
10292
+ * object. Any additional arguments are provided to `func` when it is invoked.
9921
10293
  *
9922
10294
  * @static
9923
10295
  * @memberOf _
@@ -9927,9 +10299,9 @@
9927
10299
  * @example
9928
10300
  *
9929
10301
  * // avoid throwing errors for invalid selectors
9930
- * var elements = _.attempt(function() {
10302
+ * var elements = _.attempt(function(selector) {
9931
10303
  * return document.querySelectorAll(selector);
9932
- * });
10304
+ * }, '>_>');
9933
10305
  *
9934
10306
  * if (_.isError(elements)) {
9935
10307
  * elements = [];
@@ -9937,17 +10309,18 @@
9937
10309
  */
9938
10310
  function attempt(func) {
9939
10311
  try {
9940
- return func();
10312
+ return func.apply(undefined, baseSlice(arguments, 1));
9941
10313
  } catch(e) {
9942
- return isError(e) ? e : Error(e);
10314
+ return isError(e) ? e : new Error(e);
9943
10315
  }
9944
10316
  }
9945
10317
 
9946
10318
  /**
9947
- * Creates a function bound to an optional `thisArg`. If `func` is a property
9948
- * name the created callback returns the property value for a given element.
9949
- * If `func` is an object the created callback returns `true` for elements
9950
- * that contain the equivalent object properties, otherwise it returns `false`.
10319
+ * Creates a function that invokes `func` with the `this` binding of `thisArg`
10320
+ * and arguments of the created function. If `func` is a property name the
10321
+ * created callback returns the property value for a given element. If `func`
10322
+ * is an object the created callback returns `true` for elements that contain
10323
+ * the equivalent object properties, otherwise it returns `false`.
9951
10324
  *
9952
10325
  * @static
9953
10326
  * @memberOf _
@@ -10031,6 +10404,11 @@
10031
10404
  * and `source`, returning `true` if the given object has equivalent property
10032
10405
  * values, else `false`.
10033
10406
  *
10407
+ * **Note:** This method supports comparing arrays, booleans, `Date` objects,
10408
+ * numbers, `Object` objects, regexes, and strings. Objects are compared by
10409
+ * their own, not inherited, enumerable properties. For comparing a single
10410
+ * own or inherited property value see `_.matchesProperty`.
10411
+ *
10034
10412
  * @static
10035
10413
  * @memberOf _
10036
10414
  * @category Utility
@@ -10039,22 +10417,48 @@
10039
10417
  * @example
10040
10418
  *
10041
10419
  * var users = [
10042
- * { 'user': 'fred', 'age': 40 },
10043
- * { 'user': 'barney', 'age': 36 }
10420
+ * { 'user': 'barney', 'age': 36, 'active': true },
10421
+ * { 'user': 'fred', 'age': 40, 'active': false }
10044
10422
  * ];
10045
10423
  *
10046
- * var matchesAge = _.matches({ 'age': 36 });
10047
- *
10048
- * _.filter(users, matchesAge);
10049
- * // => [{ 'user': 'barney', 'age': 36 }]
10050
- *
10051
- * _.find(users, matchesAge);
10052
- * // => { 'user': 'barney', 'age': 36 }
10424
+ * _.filter(users, _.matches({ 'age': 40, 'active': false }));
10425
+ * // => [{ 'user': 'fred', 'age': 40, 'active': false }]
10053
10426
  */
10054
10427
  function matches(source) {
10055
10428
  return baseMatches(baseClone(source, true));
10056
10429
  }
10057
10430
 
10431
+ /**
10432
+ * Creates a function which compares the property value of `key` on a given
10433
+ * object to `value`.
10434
+ *
10435
+ * **Note:** This method supports comparing arrays, booleans, `Date` objects,
10436
+ * numbers, `Object` objects, regexes, and strings. Objects are compared by
10437
+ * their own, not inherited, enumerable properties.
10438
+ *
10439
+ * @static
10440
+ * @memberOf _
10441
+ * @category Utility
10442
+ * @param {string} key The key of the property to get.
10443
+ * @param {*} value The value to compare.
10444
+ * @returns {Function} Returns the new function.
10445
+ * @example
10446
+ *
10447
+ * var users = [
10448
+ * { 'user': 'barney', 'age': 36 },
10449
+ * { 'user': 'fred', 'age': 40 },
10450
+ * { 'user': 'pebbles', 'age': 1 }
10451
+ * ];
10452
+ *
10453
+ * var matchFred = _.matchesProperty('user', 'fred');
10454
+ *
10455
+ * _.find(users, matchFred);
10456
+ * // => { 'user': 'fred', 'age': 40 }
10457
+ */
10458
+ function matchesProperty(key, value) {
10459
+ return baseMatchesProperty(key + '', baseClone(value, true));
10460
+ }
10461
+
10058
10462
  /**
10059
10463
  * Adds all own enumerable function properties of a source object to the
10060
10464
  * destination object. If `object` is a function then methods are added to
@@ -10077,6 +10481,9 @@
10077
10481
  * });
10078
10482
  * }
10079
10483
  *
10484
+ * // use `_.runInContext` to avoid potential conflicts (esp. in Node.js)
10485
+ * var _ = require('lodash').runInContext();
10486
+ *
10080
10487
  * _.mixin({ 'vowels': vowels });
10081
10488
  * _.vowels('fred');
10082
10489
  * // => ['e']
@@ -10351,7 +10758,11 @@
10351
10758
  /*------------------------------------------------------------------------*/
10352
10759
 
10353
10760
  // Ensure `new LodashWrapper` is an instance of `lodash`.
10354
- LodashWrapper.prototype = lodash.prototype;
10761
+ LodashWrapper.prototype = baseCreate(lodash.prototype);
10762
+
10763
+ // Ensure `new LazyWraper` is an instance of `LodashWrapper`
10764
+ LazyWrapper.prototype = baseCreate(LodashWrapper.prototype);
10765
+ LazyWrapper.prototype.constructor = LazyWrapper;
10355
10766
 
10356
10767
  // Add functions to the `Map` cache.
10357
10768
  MapCache.prototype['delete'] = mapDelete;
@@ -10392,6 +10803,7 @@
10392
10803
  lodash.dropRight = dropRight;
10393
10804
  lodash.dropRightWhile = dropRightWhile;
10394
10805
  lodash.dropWhile = dropWhile;
10806
+ lodash.fill = fill;
10395
10807
  lodash.filter = filter;
10396
10808
  lodash.flatten = flatten;
10397
10809
  lodash.flattenDeep = flattenDeep;
@@ -10415,6 +10827,7 @@
10415
10827
  lodash.map = map;
10416
10828
  lodash.mapValues = mapValues;
10417
10829
  lodash.matches = matches;
10830
+ lodash.matchesProperty = matchesProperty;
10418
10831
  lodash.memoize = memoize;
10419
10832
  lodash.merge = merge;
10420
10833
  lodash.mixin = mixin;
@@ -10440,6 +10853,7 @@
10440
10853
  lodash.slice = slice;
10441
10854
  lodash.sortBy = sortBy;
10442
10855
  lodash.sortByAll = sortByAll;
10856
+ lodash.spread = spread;
10443
10857
  lodash.take = take;
10444
10858
  lodash.takeRight = takeRight;
10445
10859
  lodash.takeRightWhile = takeRightWhile;
@@ -10613,14 +11027,15 @@
10613
11027
 
10614
11028
  // Add `LazyWrapper` methods that accept an `iteratee` value.
10615
11029
  arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
10616
- var isFilter = index == LAZY_FILTER_FLAG;
11030
+ var isFilter = index == LAZY_FILTER_FLAG,
11031
+ isWhile = index == LAZY_WHILE_FLAG;
10617
11032
 
10618
11033
  LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
10619
11034
  var result = this.clone(),
10620
- filtered = result.filtered,
10621
- iteratees = result.iteratees || (result.iteratees = []);
11035
+ filtered = result.__filtered__,
11036
+ iteratees = result.__iteratees__ || (result.__iteratees__ = []);
10622
11037
 
10623
- result.filtered = filtered || isFilter || (index == LAZY_WHILE_FLAG && result.dir < 0);
11038
+ result.__filtered__ = filtered || isFilter || (isWhile && result.__dir__ < 0);
10624
11039
  iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
10625
11040
  return result;
10626
11041
  };
@@ -10628,19 +11043,19 @@
10628
11043
 
10629
11044
  // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
10630
11045
  arrayEach(['drop', 'take'], function(methodName, index) {
10631
- var countName = methodName + 'Count',
11046
+ var countName = '__' + methodName + 'Count__',
10632
11047
  whileName = methodName + 'While';
10633
11048
 
10634
11049
  LazyWrapper.prototype[methodName] = function(n) {
10635
- n = n == null ? 1 : nativeMax(+n || 0, 0);
11050
+ n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
10636
11051
 
10637
11052
  var result = this.clone();
10638
- if (result.filtered) {
11053
+ if (result.__filtered__) {
10639
11054
  var value = result[countName];
10640
11055
  result[countName] = index ? nativeMin(value, n) : (value + n);
10641
11056
  } else {
10642
- var views = result.views || (result.views = []);
10643
- views.push({ 'size': n, 'type': methodName + (result.dir < 0 ? 'Right' : '') });
11057
+ var views = result.__views__ || (result.__views__ = []);
11058
+ views.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
10644
11059
  }
10645
11060
  return result;
10646
11061
  };
@@ -10656,7 +11071,7 @@
10656
11071
 
10657
11072
  // Add `LazyWrapper` methods for `_.first` and `_.last`.
10658
11073
  arrayEach(['first', 'last'], function(methodName, index) {
10659
- var takeName = 'take' + (index ? 'Right': '');
11074
+ var takeName = 'take' + (index ? 'Right' : '');
10660
11075
 
10661
11076
  LazyWrapper.prototype[methodName] = function() {
10662
11077
  return this[takeName](1).value()[0];
@@ -10678,19 +11093,18 @@
10678
11093
  createCallback = index ? baseMatches : baseProperty;
10679
11094
 
10680
11095
  LazyWrapper.prototype[methodName] = function(value) {
10681
- return this[operationName](createCallback(index ? value : (value + '')));
11096
+ return this[operationName](createCallback(value));
10682
11097
  };
10683
11098
  });
10684
11099
 
10685
- LazyWrapper.prototype.dropWhile = function(iteratee, thisArg) {
10686
- var done,
10687
- lastIndex,
10688
- isRight = this.dir < 0;
11100
+ LazyWrapper.prototype.compact = function() {
11101
+ return this.filter(identity);
11102
+ };
10689
11103
 
11104
+ LazyWrapper.prototype.dropWhile = function(iteratee, thisArg) {
11105
+ var done;
10690
11106
  iteratee = getCallback(iteratee, thisArg, 3);
10691
11107
  return this.filter(function(value, index, array) {
10692
- done = done && (isRight ? index < lastIndex : index > lastIndex);
10693
- lastIndex = index;
10694
11108
  return done || (done = !iteratee(value, index, array));
10695
11109
  });
10696
11110
  };
@@ -10713,6 +11127,10 @@
10713
11127
  return result;
10714
11128
  };
10715
11129
 
11130
+ LazyWrapper.prototype.toArray = function() {
11131
+ return this.drop(0);
11132
+ };
11133
+
10716
11134
  // Add `LazyWrapper` methods to `lodash.prototype`.
10717
11135
  baseForOwn(LazyWrapper.prototype, function(func, methodName) {
10718
11136
  var lodashFunc = lodash[methodName],
@@ -10740,8 +11158,8 @@
10740
11158
  var wrapper = onlyLazy ? value : new LazyWrapper(this),
10741
11159
  result = func.apply(wrapper, args);
10742
11160
 
10743
- if (!retUnwrapped && (isHybrid || result.actions)) {
10744
- var actions = result.actions || (result.actions = []);
11161
+ if (!retUnwrapped && (isHybrid || result.__actions__)) {
11162
+ var actions = result.__actions__ || (result.__actions__ = []);
10745
11163
  actions.push({ 'func': thru, 'args': [interceptor], 'thisArg': lodash });
10746
11164
  }
10747
11165
  return new LodashWrapper(result, chainAll);
@@ -10774,9 +11192,11 @@
10774
11192
 
10775
11193
  // Add chaining functions to the lodash wrapper.
10776
11194
  lodash.prototype.chain = wrapperChain;
11195
+ lodash.prototype.commit = wrapperCommit;
11196
+ lodash.prototype.plant = wrapperPlant;
10777
11197
  lodash.prototype.reverse = wrapperReverse;
10778
11198
  lodash.prototype.toString = wrapperToString;
10779
- lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
11199
+ lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
10780
11200
 
10781
11201
  // Add function aliases to the lodash wrapper.
10782
11202
  lodash.prototype.collect = lodash.prototype.map;