lodash-rails 1.1.1 → 1.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: 39b57e60ab8f84fb12d6619a64194413a941ce21
4
- data.tar.gz: c9f80fed80340d52a59001e339925b1cbe4992e4
3
+ metadata.gz: 0c75fa28c6e41ea63fa104d2667a6d9be3c80701
4
+ data.tar.gz: e2e427625bac90a463148d008c0842238c403915
5
5
  SHA512:
6
- metadata.gz: 68d4492e364b7effad71e9ea7183ca25f4278913a3843e35873564aa3714761139b73e368586862cdfc4e8579d397edc13c8160fa4da0d44a5b47c81cd9d5c65
7
- data.tar.gz: eeb68cf7cf38e6771d172ec4117d5df86da03b36e98f8a2df2c4d2581bcf714a0b5b055cc349bfda8526f43f86e9d0b3fb98e9abcfb647e566ffadd234e5ab96
6
+ metadata.gz: a9e6c01ff63f72e01feed04899fa9739dd8b2b2d049a800cd1f68638e4c71d3c5240992199b0b6bdb5c979c1338830d8a229f167326a667bdb27ca73da3fd09a
7
+ data.tar.gz: 510cec5d45dcee17f38d5117b21c8ce9b3657edaac5a795dcc6eb13ac65389cd42ee808295604821220746022f4049544579638e6cfa10b326fe8f3540121c18
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
- Lo-Dash 1.1.1:
21
+ Lo-Dash 1.2.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 = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Lo-Dash 1.1.1 (Custom Build) <http://lodash.com/>
3
+ * Lo-Dash 1.2.0 (Custom Build) <http://lodash.com/>
4
4
  * Build: `lodash -o ./dist/lodash.compat.js`
5
5
  * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
6
6
  * Based on Underscore.js 1.4.4 <http://underscorejs.org/>
@@ -18,9 +18,9 @@
18
18
  /** Detect free variable `module` */
19
19
  var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;
20
20
 
21
- /** Detect free variable `global` and use it as `window` */
21
+ /** Detect free variable `global`, from Node.js or Browserified code, and use it as `window` */
22
22
  var freeGlobal = typeof global == 'object' && global;
23
- if (freeGlobal.global === freeGlobal) {
23
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
24
24
  window = freeGlobal;
25
25
  }
26
26
 
@@ -30,6 +30,12 @@
30
30
  /** Used internally to indicate various things */
31
31
  var indicatorObject = {};
32
32
 
33
+ /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
34
+ var keyPrefix = +new Date + '';
35
+
36
+ /** Used as the size when optimizations are enabled for large arrays */
37
+ var largeArraySize = 200;
38
+
33
39
  /** Used to match empty string literals in compiled template source */
34
40
  var reEmptyStringLeading = /\b__p \+= '';/g,
35
41
  reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
@@ -175,7 +181,7 @@
175
181
  toString = objectRef.toString;
176
182
 
177
183
  /* Native method shortcuts for methods with the same name as other `lodash` methods */
178
- var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
184
+ var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
179
185
  nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
180
186
  nativeIsFinite = context.isFinite,
181
187
  nativeIsNaN = context.isNaN,
@@ -183,7 +189,8 @@
183
189
  nativeMax = Math.max,
184
190
  nativeMin = Math.min,
185
191
  nativeParseInt = context.parseInt,
186
- nativeRandom = Math.random;
192
+ nativeRandom = Math.random,
193
+ nativeSlice = arrayRef.slice;
187
194
 
188
195
  /** Detect various environments */
189
196
  var isIeOpera = reNative.test(context.attachEvent),
@@ -202,7 +209,7 @@
202
209
  /*--------------------------------------------------------------------------*/
203
210
 
204
211
  /**
205
- * Creates a `lodash` object, that wraps the given `value`, to enable method
212
+ * Creates a `lodash` object, which wraps the given `value`, to enable method
206
213
  * chaining.
207
214
  *
208
215
  * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
@@ -220,8 +227,8 @@
220
227
  * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
221
228
  * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
222
229
  * `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
223
- * `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`,
224
- * `where`, `without`, `wrap`, and `zip`
230
+ * `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `unzip`,
231
+ * `values`, `where`, `without`, `wrap`, and `zip`
225
232
  *
226
233
  * The non-chainable wrapper functions are:
227
234
  * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
@@ -240,6 +247,26 @@
240
247
  * @category Chaining
241
248
  * @param {Mixed} value The value to wrap in a `lodash` instance.
242
249
  * @returns {Object} Returns a `lodash` instance.
250
+ * @example
251
+ *
252
+ * var wrapped = _([1, 2, 3]);
253
+ *
254
+ * // returns an unwrapped value
255
+ * wrapped.reduce(function(sum, num) {
256
+ * return sum + num;
257
+ * });
258
+ * // => 6
259
+ *
260
+ * // returns a wrapped value
261
+ * var squares = wrapped.map(function(num) {
262
+ * return num * num;
263
+ * });
264
+ *
265
+ * _.isArray(squares);
266
+ * // => false
267
+ *
268
+ * _.isArray(squares.value());
269
+ * // => true
243
270
  */
244
271
  function lodash(value) {
245
272
  // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
@@ -267,12 +294,12 @@
267
294
  for (prop in arguments) { }
268
295
 
269
296
  /**
270
- * Detect if `arguments` objects are `Object` objects (all but Opera < 10.5).
297
+ * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5).
271
298
  *
272
299
  * @memberOf _.support
273
300
  * @type Boolean
274
301
  */
275
- support.argsObject = arguments.constructor == Object;
302
+ support.argsObject = arguments.constructor == Object && !(arguments instanceof Array);
276
303
 
277
304
  /**
278
305
  * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9).
@@ -438,7 +465,7 @@
438
465
  * The template used to create iterator functions.
439
466
  *
440
467
  * @private
441
- * @param {Obect} data The data object used to populate the text.
468
+ * @param {Object} data The data object used to populate the text.
442
469
  * @returns {String} Returns the interpolated text.
443
470
  */
444
471
  var iteratorTemplate = function(obj) {
@@ -566,31 +593,27 @@
566
593
  * @private
567
594
  * @param {Array} array The array to search.
568
595
  * @param {Mixed} value The value to search for.
569
- * @param {Number} fromIndex The index to search from.
570
- * @param {Number} largeSize The length at which an array is considered large.
571
596
  * @returns {Boolean} Returns `true`, if `value` is found, else `false`.
572
597
  */
573
- function cachedContains(array, fromIndex, largeSize) {
598
+ function cachedContains(array) {
574
599
  var length = array.length,
575
- isLarge = (length - fromIndex) >= largeSize;
600
+ isLarge = length >= largeArraySize;
576
601
 
577
602
  if (isLarge) {
578
603
  var cache = {},
579
- index = fromIndex - 1;
604
+ index = -1;
580
605
 
581
606
  while (++index < length) {
582
- // manually coerce `value` to a string because `hasOwnProperty`, in some
583
- // older versions of Firefox, coerces objects incorrectly
584
- var key = String(array[index]);
585
- (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]);
607
+ var key = keyPrefix + array[index];
608
+ (cache[key] || (cache[key] = [])).push(array[index]);
586
609
  }
587
610
  }
588
611
  return function(value) {
589
612
  if (isLarge) {
590
- var key = String(value);
591
- return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1;
613
+ var key = keyPrefix + value;
614
+ return cache[key] && indexOf(cache[key], value) > -1;
592
615
  }
593
- return indexOf(array, value, fromIndex) > -1;
616
+ return indexOf(array, value) > -1;
594
617
  }
595
618
  }
596
619
 
@@ -676,7 +699,7 @@
676
699
  }
677
700
  if (partialArgs.length) {
678
701
  args = args.length
679
- ? (args = slice(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args))
702
+ ? (args = nativeSlice.call(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args))
680
703
  : partialArgs;
681
704
  }
682
705
  if (this instanceof bound) {
@@ -702,6 +725,7 @@
702
725
  * @param {Object} [options1, options2, ...] The compile options object(s).
703
726
  * arrays - A string of code to determine if the iterable is an array or array-like.
704
727
  * useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
728
+ * useKeys - A boolean to specify using `_.keys` for own property iteration.
705
729
  * args - A string of comma separated arguments the iteration function will accept.
706
730
  * top - A string of code to execute before the iteration branches.
707
731
  * loop - A string of code to execute in the object loop.
@@ -803,7 +827,7 @@
803
827
  }
804
828
 
805
829
  /**
806
- * A fallback implementation of `isPlainObject` that checks if a given `value`
830
+ * A fallback implementation of `isPlainObject` which checks if a given `value`
807
831
  * is an object created by the `Object` constructor, assuming objects created
808
832
  * by the `Object` constructor have no inherited enumerable properties and that
809
833
  * there are no `Object.prototype` extensions.
@@ -911,29 +935,7 @@
911
935
  }
912
936
 
913
937
  /**
914
- * Checks if `value` is an array.
915
- *
916
- * @static
917
- * @memberOf _
918
- * @category Objects
919
- * @param {Mixed} value The value to check.
920
- * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
921
- * @example
922
- *
923
- * (function() { return _.isArray(arguments); })();
924
- * // => false
925
- *
926
- * _.isArray([1, 2, 3]);
927
- * // => true
928
- */
929
- var isArray = nativeIsArray || function(value) {
930
- // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
931
- // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
932
- return (support.argsObject && value instanceof Array) || toString.call(value) == arrayClass;
933
- };
934
-
935
- /**
936
- * A fallback implementation of `Object.keys` that produces an array of the
938
+ * A fallback implementation of `Object.keys` which produces an array of the
937
939
  * given object's own enumerable property names.
938
940
  *
939
941
  * @private
@@ -1253,7 +1255,7 @@
1253
1255
  * @static
1254
1256
  * @memberOf _
1255
1257
  * @category Objects
1256
- * @param {Array|Object|String} collection The collection to iterate over.
1258
+ * @param {Object} object The object to search.
1257
1259
  * @param {Function|Object|String} [callback=identity] The function called per
1258
1260
  * iteration. If a property name or object is passed, it will be used to create
1259
1261
  * a "_.pluck" or "_.where" style callback, respectively.
@@ -1261,14 +1263,16 @@
1261
1263
  * @returns {Mixed} Returns the key of the found element, else `undefined`.
1262
1264
  * @example
1263
1265
  *
1264
- * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; });
1266
+ * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) {
1267
+ * return num % 2 == 0;
1268
+ * });
1265
1269
  * // => 'b'
1266
1270
  */
1267
- function findKey(collection, callback, thisArg) {
1271
+ function findKey(object, callback, thisArg) {
1268
1272
  var result;
1269
1273
  callback = lodash.createCallback(callback, thisArg);
1270
- forOwn(collection, function(value, key, collection) {
1271
- if (callback(value, key, collection)) {
1274
+ forOwn(object, function(value, key, object) {
1275
+ if (callback(value, key, object)) {
1272
1276
  result = key;
1273
1277
  return false;
1274
1278
  }
@@ -1402,6 +1406,29 @@
1402
1406
  return result;
1403
1407
  }
1404
1408
 
1409
+ /**
1410
+ * Checks if `value` is an array.
1411
+ *
1412
+ * @static
1413
+ * @memberOf _
1414
+ * @category Objects
1415
+ * @param {Mixed} value The value to check.
1416
+ * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
1417
+ * @example
1418
+ *
1419
+ * (function() { return _.isArray(arguments); })();
1420
+ * // => false
1421
+ *
1422
+ * _.isArray([1, 2, 3]);
1423
+ * // => true
1424
+ */
1425
+ function isArray(value) {
1426
+ // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
1427
+ // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
1428
+ return (support.argsObject && value instanceof Array) ||
1429
+ (nativeIsArray ? nativeIsArray(value) : toString.call(value) == arrayClass);
1430
+ }
1431
+
1405
1432
  /**
1406
1433
  * Checks if `value` is a boolean value.
1407
1434
  *
@@ -1536,11 +1563,8 @@
1536
1563
  function isEqual(a, b, callback, thisArg, stackA, stackB) {
1537
1564
  // used to indicate that when comparing objects, `a` has at least the properties of `b`
1538
1565
  var whereIndicator = callback === indicatorObject;
1539
- if (callback && !whereIndicator) {
1540
- callback = (typeof thisArg == 'undefined')
1541
- ? callback
1542
- : lodash.createCallback(callback, thisArg, 2);
1543
-
1566
+ if (typeof callback == 'function' && !whereIndicator) {
1567
+ callback = lodash.createCallback(callback, thisArg, 2);
1544
1568
  var result = callback(a, b);
1545
1569
  if (typeof result != 'undefined') {
1546
1570
  return !!result;
@@ -2026,22 +2050,24 @@
2026
2050
  }
2027
2051
  }
2028
2052
  if (!found) {
2029
- value = isArr
2030
- ? (isArray(value) ? value : [])
2031
- : (isPlainObject(value) ? value : {});
2032
-
2053
+ var isShallow;
2033
2054
  if (callback) {
2034
2055
  result = callback(value, source);
2035
- if (typeof result != 'undefined') {
2056
+ if ((isShallow = typeof result != 'undefined')) {
2036
2057
  value = result;
2037
2058
  }
2038
2059
  }
2060
+ if (!isShallow) {
2061
+ value = isArr
2062
+ ? (isArray(value) ? value : [])
2063
+ : (isPlainObject(value) ? value : {});
2064
+ }
2039
2065
  // add `source` and associated `value` to the stack of traversed objects
2040
2066
  stackA.push(source);
2041
2067
  stackB.push(value);
2042
2068
 
2043
2069
  // recursively merge objects and arrays (susceptible to call stack limits)
2044
- if (!callback) {
2070
+ if (!isShallow) {
2045
2071
  value = merge(value, source, indicatorObject, callback, stackA, stackB);
2046
2072
  }
2047
2073
  }
@@ -2096,12 +2122,12 @@
2096
2122
  if (isFunc) {
2097
2123
  callback = lodash.createCallback(callback, thisArg);
2098
2124
  } else {
2099
- var props = concat.apply(arrayRef, arguments);
2125
+ var props = concat.apply(arrayRef, nativeSlice.call(arguments, 1));
2100
2126
  }
2101
2127
  forIn(object, function(value, key, object) {
2102
2128
  if (isFunc
2103
2129
  ? !callback(value, key, object)
2104
- : indexOf(props, key, 1) < 0
2130
+ : indexOf(props, key) < 0
2105
2131
  ) {
2106
2132
  result[key] = value;
2107
2133
  }
@@ -2164,8 +2190,8 @@
2164
2190
  function pick(object, callback, thisArg) {
2165
2191
  var result = {};
2166
2192
  if (typeof callback != 'function') {
2167
- var index = 0,
2168
- props = concat.apply(arrayRef, arguments),
2193
+ var index = -1,
2194
+ props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
2169
2195
  length = isObject(object) ? props.length : 0;
2170
2196
 
2171
2197
  while (++index < length) {
@@ -2235,7 +2261,7 @@
2235
2261
  */
2236
2262
  function at(collection) {
2237
2263
  var index = -1,
2238
- props = concat.apply(arrayRef, slice(arguments, 1)),
2264
+ props = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
2239
2265
  length = props.length,
2240
2266
  result = Array(length);
2241
2267
 
@@ -2490,7 +2516,9 @@
2490
2516
  * @returns {Mixed} Returns the found element, else `undefined`.
2491
2517
  * @example
2492
2518
  *
2493
- * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; });
2519
+ * _.find([1, 2, 3, 4], function(num) {
2520
+ * return num % 2 == 0;
2521
+ * });
2494
2522
  * // => 2
2495
2523
  *
2496
2524
  * var food = [
@@ -2638,7 +2666,7 @@
2638
2666
  * // => [['1', '2', '3'], ['4', '5', '6']]
2639
2667
  */
2640
2668
  function invoke(collection, methodName) {
2641
- var args = slice(arguments, 2),
2669
+ var args = nativeSlice.call(arguments, 2),
2642
2670
  index = -1,
2643
2671
  isFunc = typeof methodName == 'function',
2644
2672
  length = collection ? collection.length : 0,
@@ -2868,7 +2896,7 @@
2868
2896
  var pluck = map;
2869
2897
 
2870
2898
  /**
2871
- * Reduces a `collection` to a value that is the accumulated result of running
2899
+ * Reduces a `collection` to a value which is the accumulated result of running
2872
2900
  * each element in the `collection` through the `callback`, where each successive
2873
2901
  * `callback` execution consumes the return value of the previous execution.
2874
2902
  * If `accumulator` is not passed, the first element of the `collection` will be
@@ -3275,8 +3303,8 @@
3275
3303
  function difference(array) {
3276
3304
  var index = -1,
3277
3305
  length = array ? array.length : 0,
3278
- flattened = concat.apply(arrayRef, arguments),
3279
- contains = cachedContains(flattened, length, 100),
3306
+ flattened = concat.apply(arrayRef, nativeSlice.call(arguments, 1)),
3307
+ contains = cachedContains(flattened),
3280
3308
  result = [];
3281
3309
 
3282
3310
  while (++index < length) {
@@ -3295,7 +3323,7 @@
3295
3323
  * @static
3296
3324
  * @memberOf _
3297
3325
  * @category Arrays
3298
- * @param {Array|Object|String} collection The collection to iterate over.
3326
+ * @param {Array} array The array to search.
3299
3327
  * @param {Function|Object|String} [callback=identity] The function called per
3300
3328
  * iteration. If a property name or object is passed, it will be used to create
3301
3329
  * a "_.pluck" or "_.where" style callback, respectively.
@@ -3303,16 +3331,18 @@
3303
3331
  * @returns {Mixed} Returns the index of the found element, else `-1`.
3304
3332
  * @example
3305
3333
  *
3306
- * _.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); });
3334
+ * _.findIndex(['apple', 'banana', 'beet'], function(food) {
3335
+ * return /^b/.test(food);
3336
+ * });
3307
3337
  * // => 1
3308
3338
  */
3309
- function findIndex(collection, callback, thisArg) {
3339
+ function findIndex(array, callback, thisArg) {
3310
3340
  var index = -1,
3311
- length = collection ? collection.length : 0;
3341
+ length = array ? array.length : 0;
3312
3342
 
3313
3343
  callback = lodash.createCallback(callback, thisArg);
3314
3344
  while (++index < length) {
3315
- if (callback(collection[index], index, collection)) {
3345
+ if (callback(array[index], index, array)) {
3316
3346
  return index;
3317
3347
  }
3318
3348
  }
@@ -3414,7 +3444,7 @@
3414
3444
  * @static
3415
3445
  * @memberOf _
3416
3446
  * @category Arrays
3417
- * @param {Array} array The array to compact.
3447
+ * @param {Array} array The array to flatten.
3418
3448
  * @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
3419
3449
  * @param {Function|Object|String} [callback=identity] The function called per
3420
3450
  * iteration. If a property name or object is passed, it will be used to create
@@ -3605,7 +3635,7 @@
3605
3635
  cache = { '0': {} },
3606
3636
  index = -1,
3607
3637
  length = array ? array.length : 0,
3608
- isLarge = length >= 100,
3638
+ isLarge = length >= largeArraySize,
3609
3639
  result = [],
3610
3640
  seen = result;
3611
3641
 
@@ -3613,8 +3643,8 @@
3613
3643
  while (++index < length) {
3614
3644
  var value = array[index];
3615
3645
  if (isLarge) {
3616
- var key = String(value);
3617
- var inited = hasOwnProperty.call(cache[0], key)
3646
+ var key = keyPrefix + value;
3647
+ var inited = cache[0][key]
3618
3648
  ? !(seen = cache[0][key])
3619
3649
  : (seen = cache[0][key] = []);
3620
3650
  }
@@ -3624,7 +3654,7 @@
3624
3654
  }
3625
3655
  var argsIndex = argsLength;
3626
3656
  while (--argsIndex) {
3627
- if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex], 0, 100)))(value)) {
3657
+ if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex])))(value)) {
3628
3658
  continue outer;
3629
3659
  }
3630
3660
  }
@@ -3885,7 +3915,7 @@
3885
3915
  * @static
3886
3916
  * @memberOf _
3887
3917
  * @category Arrays
3888
- * @param {Array} array The array to iterate over.
3918
+ * @param {Array} array The array to inspect.
3889
3919
  * @param {Mixed} value The value to evaluate.
3890
3920
  * @param {Function|Object|String} [callback=identity] The function called per
3891
3921
  * iteration. If a property name or object is passed, it will be used to create
@@ -3948,7 +3978,10 @@
3948
3978
  * _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
3949
3979
  * // => [1, 2, 3, 101, 10]
3950
3980
  */
3951
- function union() {
3981
+ function union(array) {
3982
+ if (!isArray(array)) {
3983
+ arguments[0] = array ? nativeSlice.call(array) : arrayRef;
3984
+ }
3952
3985
  return uniq(concat.apply(arrayRef, arguments));
3953
3986
  }
3954
3987
 
@@ -4008,7 +4041,7 @@
4008
4041
  isSorted = false;
4009
4042
  }
4010
4043
  // init value cache for large arrays
4011
- var isLarge = !isSorted && length >= 75;
4044
+ var isLarge = !isSorted && length >= largeArraySize;
4012
4045
  if (isLarge) {
4013
4046
  var cache = {};
4014
4047
  }
@@ -4021,8 +4054,8 @@
4021
4054
  computed = callback ? callback(value, index, array) : value;
4022
4055
 
4023
4056
  if (isLarge) {
4024
- var key = String(computed);
4025
- var inited = hasOwnProperty.call(cache, key)
4057
+ var key = keyPrefix + computed;
4058
+ var inited = cache[key]
4026
4059
  ? !(seen = cache[key])
4027
4060
  : (seen = cache[key] = []);
4028
4061
  }
@@ -4039,6 +4072,37 @@
4039
4072
  return result;
4040
4073
  }
4041
4074
 
4075
+ /**
4076
+ * The inverse of `_.zip`, this method splits groups of elements into arrays
4077
+ * composed of elements from each group at their corresponding indexes.
4078
+ *
4079
+ * @static
4080
+ * @memberOf _
4081
+ * @category Arrays
4082
+ * @param {Array} array The array to process.
4083
+ * @returns {Array} Returns a new array of the composed arrays.
4084
+ * @example
4085
+ *
4086
+ * _.unzip([['moe', 30, true], ['larry', 40, false]]);
4087
+ * // => [['moe', 'larry'], [30, 40], [true, false]];
4088
+ */
4089
+ function unzip(array) {
4090
+ var index = -1,
4091
+ length = array ? array.length : 0,
4092
+ tupleLength = length ? max(pluck(array, 'length')) : 0,
4093
+ result = Array(tupleLength);
4094
+
4095
+ while (++index < length) {
4096
+ var tupleIndex = -1,
4097
+ tuple = array[index];
4098
+
4099
+ while (++tupleIndex < tupleLength) {
4100
+ (result[tupleIndex] || (result[tupleIndex] = Array(length)))[index] = tuple[tupleIndex];
4101
+ }
4102
+ }
4103
+ return result;
4104
+ }
4105
+
4042
4106
  /**
4043
4107
  * Creates an array with all occurrences of the passed values removed using
4044
4108
  * strict equality for comparisons, i.e. `===`.
@@ -4055,18 +4119,7 @@
4055
4119
  * // => [2, 3, 4]
4056
4120
  */
4057
4121
  function without(array) {
4058
- var index = -1,
4059
- length = array ? array.length : 0,
4060
- contains = cachedContains(arguments, 1, 30),
4061
- result = [];
4062
-
4063
- while (++index < length) {
4064
- var value = array[index];
4065
- if (!contains(value)) {
4066
- result.push(value);
4067
- }
4068
- }
4069
- return result;
4122
+ return difference(array, nativeSlice.call(arguments, 1));
4070
4123
  }
4071
4124
 
4072
4125
  /**
@@ -4192,7 +4245,7 @@
4192
4245
  // (in V8 `Function#bind` is slower except when partially applied)
4193
4246
  return support.fastBind || (nativeBind && arguments.length > 2)
4194
4247
  ? nativeBind.call.apply(nativeBind, arguments)
4195
- : createBound(func, thisArg, slice(arguments, 2));
4248
+ : createBound(func, thisArg, nativeSlice.call(arguments, 2));
4196
4249
  }
4197
4250
 
4198
4251
  /**
@@ -4219,8 +4272,8 @@
4219
4272
  * // => alerts 'clicked docs', when the button is clicked
4220
4273
  */
4221
4274
  function bindAll(object) {
4222
- var funcs = concat.apply(arrayRef, arguments),
4223
- index = funcs.length > 1 ? 0 : (funcs = functions(object), -1),
4275
+ var funcs = arguments.length > 1 ? concat.apply(arrayRef, nativeSlice.call(arguments, 1)) : functions(object),
4276
+ index = -1,
4224
4277
  length = funcs.length;
4225
4278
 
4226
4279
  while (++index < length) {
@@ -4265,7 +4318,7 @@
4265
4318
  * // => 'hi, moe!'
4266
4319
  */
4267
4320
  function bindKey(object, key) {
4268
- return createBound(object, key, slice(arguments, 2), indicatorObject);
4321
+ return createBound(object, key, nativeSlice.call(arguments, 2), indicatorObject);
4269
4322
  }
4270
4323
 
4271
4324
  /**
@@ -4395,44 +4448,53 @@
4395
4448
  /**
4396
4449
  * Creates a function that will delay the execution of `func` until after
4397
4450
  * `wait` milliseconds have elapsed since the last time it was invoked. Pass
4398
- * `true` for `immediate` to cause debounce to invoke `func` on the leading,
4399
- * instead of the trailing, edge of the `wait` timeout. Subsequent calls to
4400
- * the debounced function will return the result of the last `func` call.
4451
+ * an `options` object to indicate that `func` should be invoked on the leading
4452
+ * and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced
4453
+ * function will return the result of the last `func` call.
4401
4454
  *
4402
4455
  * @static
4403
4456
  * @memberOf _
4404
4457
  * @category Functions
4405
4458
  * @param {Function} func The function to debounce.
4406
4459
  * @param {Number} wait The number of milliseconds to delay.
4407
- * @param {Boolean} immediate A flag to indicate execution is on the leading
4408
- * edge of the timeout.
4460
+ * @param {Object} options The options object.
4461
+ * [leading=false] A boolean to specify execution on the leading edge of the timeout.
4462
+ * [trailing=true] A boolean to specify execution on the trailing edge of the timeout.
4409
4463
  * @returns {Function} Returns the new debounced function.
4410
4464
  * @example
4411
4465
  *
4412
4466
  * var lazyLayout = _.debounce(calculateLayout, 300);
4413
4467
  * jQuery(window).on('resize', lazyLayout);
4414
4468
  */
4415
- function debounce(func, wait, immediate) {
4469
+ function debounce(func, wait, options) {
4416
4470
  var args,
4417
4471
  result,
4418
4472
  thisArg,
4419
- timeoutId;
4473
+ timeoutId,
4474
+ trailing = true;
4420
4475
 
4421
4476
  function delayed() {
4422
4477
  timeoutId = null;
4423
- if (!immediate) {
4478
+ if (trailing) {
4424
4479
  result = func.apply(thisArg, args);
4425
4480
  }
4426
4481
  }
4482
+ if (options === true) {
4483
+ var leading = true;
4484
+ trailing = false;
4485
+ } else if (options && objectTypes[typeof options]) {
4486
+ leading = options.leading;
4487
+ trailing = 'trailing' in options ? options.trailing : trailing;
4488
+ }
4427
4489
  return function() {
4428
- var isImmediate = immediate && !timeoutId;
4490
+ var isLeading = leading && !timeoutId;
4429
4491
  args = arguments;
4430
4492
  thisArg = this;
4431
4493
 
4432
4494
  clearTimeout(timeoutId);
4433
4495
  timeoutId = setTimeout(delayed, wait);
4434
4496
 
4435
- if (isImmediate) {
4497
+ if (isLeading) {
4436
4498
  result = func.apply(thisArg, args);
4437
4499
  }
4438
4500
  return result;
@@ -4455,7 +4517,7 @@
4455
4517
  * // returns from the function before `alert` is called
4456
4518
  */
4457
4519
  function defer(func) {
4458
- var args = slice(arguments, 1);
4520
+ var args = nativeSlice.call(arguments, 1);
4459
4521
  return setTimeout(function() { func.apply(undefined, args); }, 1);
4460
4522
  }
4461
4523
  // use `setImmediate` if it's available in Node.js
@@ -4481,7 +4543,7 @@
4481
4543
  * // => 'logged later' (Appears after one second.)
4482
4544
  */
4483
4545
  function delay(func, wait) {
4484
- var args = slice(arguments, 2);
4546
+ var args = nativeSlice.call(arguments, 2);
4485
4547
  return setTimeout(function() { func.apply(undefined, args); }, wait);
4486
4548
  }
4487
4549
 
@@ -4507,7 +4569,7 @@
4507
4569
  function memoize(func, resolver) {
4508
4570
  var cache = {};
4509
4571
  return function() {
4510
- var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]);
4572
+ var key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]);
4511
4573
  return hasOwnProperty.call(cache, key)
4512
4574
  ? cache[key]
4513
4575
  : (cache[key] = func.apply(this, arguments));
@@ -4567,7 +4629,7 @@
4567
4629
  * // => 'hi moe'
4568
4630
  */
4569
4631
  function partial(func) {
4570
- return createBound(func, slice(arguments, 1));
4632
+ return createBound(func, nativeSlice.call(arguments, 1));
4571
4633
  }
4572
4634
 
4573
4635
  /**
@@ -4598,43 +4660,61 @@
4598
4660
  * // => { '_': _, 'jq': $ }
4599
4661
  */
4600
4662
  function partialRight(func) {
4601
- return createBound(func, slice(arguments, 1), null, indicatorObject);
4663
+ return createBound(func, nativeSlice.call(arguments, 1), null, indicatorObject);
4602
4664
  }
4603
4665
 
4604
4666
  /**
4605
- * Creates a function that, when executed, will only call the `func`
4606
- * function at most once per every `wait` milliseconds. If the throttled
4607
- * function is invoked more than once during the `wait` timeout, `func` will
4608
- * also be called on the trailing edge of the timeout. Subsequent calls to the
4609
- * throttled function will return the result of the last `func` call.
4667
+ * Creates a function that, when executed, will only call the `func` function
4668
+ * at most once per every `wait` milliseconds. If the throttled function is
4669
+ * invoked more than once during the `wait` timeout, `func` will also be called
4670
+ * on the trailing edge of the timeout. Pass an `options` object to indicate
4671
+ * that `func` should be invoked on the leading and/or trailing edge of the
4672
+ * `wait` timeout. Subsequent calls to the throttled function will return
4673
+ * the result of the last `func` call.
4610
4674
  *
4611
4675
  * @static
4612
4676
  * @memberOf _
4613
4677
  * @category Functions
4614
4678
  * @param {Function} func The function to throttle.
4615
4679
  * @param {Number} wait The number of milliseconds to throttle executions to.
4680
+ * @param {Object} options The options object.
4681
+ * [leading=true] A boolean to specify execution on the leading edge of the timeout.
4682
+ * [trailing=true] A boolean to specify execution on the trailing edge of the timeout.
4616
4683
  * @returns {Function} Returns the new throttled function.
4617
4684
  * @example
4618
4685
  *
4619
4686
  * var throttled = _.throttle(updatePosition, 100);
4620
4687
  * jQuery(window).on('scroll', throttled);
4621
4688
  */
4622
- function throttle(func, wait) {
4689
+ function throttle(func, wait, options) {
4623
4690
  var args,
4624
4691
  result,
4625
4692
  thisArg,
4626
4693
  timeoutId,
4627
- lastCalled = 0;
4694
+ lastCalled = 0,
4695
+ leading = true,
4696
+ trailing = true;
4628
4697
 
4629
4698
  function trailingCall() {
4630
4699
  lastCalled = new Date;
4631
4700
  timeoutId = null;
4632
- result = func.apply(thisArg, args);
4701
+
4702
+ if (trailing) {
4703
+ result = func.apply(thisArg, args);
4704
+ }
4705
+ }
4706
+ if (options === false) {
4707
+ leading = false;
4708
+ } else if (options && objectTypes[typeof options]) {
4709
+ leading = 'leading' in options ? options.leading : leading;
4710
+ trailing = 'trailing' in options ? options.trailing : trailing;
4633
4711
  }
4634
4712
  return function() {
4635
- var now = new Date,
4636
- remaining = wait - (now - lastCalled);
4637
-
4713
+ var now = new Date;
4714
+ if (!timeoutId && !leading) {
4715
+ lastCalled = now;
4716
+ }
4717
+ var remaining = wait - (now - lastCalled);
4638
4718
  args = arguments;
4639
4719
  thisArg = this;
4640
4720
 
@@ -4864,9 +4944,6 @@
4864
4944
  * Note: In the development build, `_.template` utilizes sourceURLs for easier
4865
4945
  * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
4866
4946
  *
4867
- * Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp`
4868
- * build and using precompiled templates, or loading Lo-Dash in a sandbox.
4869
- *
4870
4947
  * For more information on precompiling templates see:
4871
4948
  * http://lodash.com/#custom-builds
4872
4949
  *
@@ -4877,7 +4954,7 @@
4877
4954
  * @memberOf _
4878
4955
  * @category Utilities
4879
4956
  * @param {String} text The template text.
4880
- * @param {Obect} data The data object used to populate the text.
4957
+ * @param {Object} data The data object used to populate the text.
4881
4958
  * @param {Object} options The options object.
4882
4959
  * escape - The "escape" delimiter regexp.
4883
4960
  * evaluate - The "evaluate" delimiter regexp.
@@ -5077,7 +5154,7 @@
5077
5154
  }
5078
5155
 
5079
5156
  /**
5080
- * The opposite of `_.escape`, this method converts the HTML entities
5157
+ * The inverse of `_.escape`, this method converts the HTML entities
5081
5158
  * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their
5082
5159
  * corresponding characters.
5083
5160
  *
@@ -5230,6 +5307,7 @@
5230
5307
  lodash.toArray = toArray;
5231
5308
  lodash.union = union;
5232
5309
  lodash.uniq = uniq;
5310
+ lodash.unzip = unzip;
5233
5311
  lodash.values = values;
5234
5312
  lodash.where = where;
5235
5313
  lodash.without = without;
@@ -5347,7 +5425,7 @@
5347
5425
  * @memberOf _
5348
5426
  * @type String
5349
5427
  */
5350
- lodash.VERSION = '1.1.1';
5428
+ lodash.VERSION = '1.2.0';
5351
5429
 
5352
5430
  // add "Chaining" functions to the wrapper
5353
5431
  lodash.prototype.toString = wrapperToString;