Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / ibrik / node_modules / lodash / lodash.js
1 /**
2  * @license
3  * Lo-Dash 2.4.2 <https://lodash.com/>
4  * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
5  * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
6  * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
7  * Available under MIT license <https://lodash.com/license>
8  */
9 ;(function() {
10
11   /** Used as a safe reference for `undefined` in pre ES5 environments */
12   var undefined;
13
14   /** Used to pool arrays and objects used internally */
15   var arrayPool = [],
16       objectPool = [];
17
18   /** Used to generate unique IDs */
19   var idCounter = 0;
20
21   /** Used internally to indicate various things */
22   var indicatorObject = {};
23
24   /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
25   var keyPrefix = +new Date + '';
26
27   /** Used as the size when optimizations are enabled for large arrays */
28   var largeArraySize = 75;
29
30   /** Used as the max size of the `arrayPool` and `objectPool` */
31   var maxPoolSize = 40;
32
33   /** Used to detect and test whitespace */
34   var whitespace = (
35     // whitespace
36     ' \t\x0B\f\xA0\ufeff' +
37
38     // line terminators
39     '\n\r\u2028\u2029' +
40
41     // unicode category "Zs" space separators
42     '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'
43   );
44
45   /** Used to match empty string literals in compiled template source */
46   var reEmptyStringLeading = /\b__p \+= '';/g,
47       reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
48       reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
49
50   /**
51    * Used to match ES6 template delimiters
52    * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals
53    */
54   var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
55
56   /** Used to match regexp flags from their coerced string values */
57   var reFlags = /\w*$/;
58
59   /** Used to detected named functions */
60   var reFuncName = /^\s*function[ \n\r\t]+\w/;
61
62   /** Used to match "interpolate" template delimiters */
63   var reInterpolate = /<%=([\s\S]+?)%>/g;
64
65   /** Used to match leading whitespace and zeros to be removed */
66   var reLeadingSpacesAndZeros = RegExp('^[' + whitespace + ']*0+(?=.$)');
67
68   /** Used to ensure capturing order of template delimiters */
69   var reNoMatch = /($^)/;
70
71   /** Used to detect functions containing a `this` reference */
72   var reThis = /\bthis\b/;
73
74   /** Used to match unescaped characters in compiled string literals */
75   var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g;
76
77   /** Used to assign default `context` object properties */
78   var contextProps = [
79     'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object',
80     'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN',
81     'parseInt', 'setTimeout'
82   ];
83
84   /** Used to fix the JScript [[DontEnum]] bug */
85   var shadowedProps = [
86     'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
87     'toLocaleString', 'toString', 'valueOf'
88   ];
89
90   /** Used to make template sourceURLs easier to identify */
91   var templateCounter = 0;
92
93   /** `Object#toString` result shortcuts */
94   var argsClass = '[object Arguments]',
95       arrayClass = '[object Array]',
96       boolClass = '[object Boolean]',
97       dateClass = '[object Date]',
98       errorClass = '[object Error]',
99       funcClass = '[object Function]',
100       numberClass = '[object Number]',
101       objectClass = '[object Object]',
102       regexpClass = '[object RegExp]',
103       stringClass = '[object String]';
104
105   /** Used to identify object classifications that `_.clone` supports */
106   var cloneableClasses = {};
107   cloneableClasses[funcClass] = false;
108   cloneableClasses[argsClass] = cloneableClasses[arrayClass] =
109   cloneableClasses[boolClass] = cloneableClasses[dateClass] =
110   cloneableClasses[numberClass] = cloneableClasses[objectClass] =
111   cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true;
112
113   /** Used as an internal `_.debounce` options object */
114   var debounceOptions = {
115     'leading': false,
116     'maxWait': 0,
117     'trailing': false
118   };
119
120   /** Used as the property descriptor for `__bindData__` */
121   var descriptor = {
122     'configurable': false,
123     'enumerable': false,
124     'value': null,
125     'writable': false
126   };
127
128   /** Used as the data object for `iteratorTemplate` */
129   var iteratorData = {
130     'args': '',
131     'array': null,
132     'bottom': '',
133     'firstArg': '',
134     'init': '',
135     'keys': null,
136     'loop': '',
137     'shadowedProps': null,
138     'support': null,
139     'top': '',
140     'useHas': false
141   };
142
143   /** Used to determine if values are of the language type Object */
144   var objectTypes = {
145     'boolean': false,
146     'function': true,
147     'object': true,
148     'number': false,
149     'string': false,
150     'undefined': false
151   };
152
153   /** Used to escape characters for inclusion in compiled string literals */
154   var stringEscapes = {
155     '\\': '\\',
156     "'": "'",
157     '\n': 'n',
158     '\r': 'r',
159     '\t': 't',
160     '\u2028': 'u2028',
161     '\u2029': 'u2029'
162   };
163
164   /** Used as a reference to the global object */
165   var root = (objectTypes[typeof window] && window) || this;
166
167   /** Detect free variable `exports` */
168   var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
169
170   /** Detect free variable `module` */
171   var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
172
173   /** Detect the popular CommonJS extension `module.exports` */
174   var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
175
176   /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
177   var freeGlobal = objectTypes[typeof global] && global;
178   if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
179     root = freeGlobal;
180   }
181
182   /*--------------------------------------------------------------------------*/
183
184   /**
185    * The base implementation of `_.indexOf` without support for binary searches
186    * or `fromIndex` constraints.
187    *
188    * @private
189    * @param {Array} array The array to search.
190    * @param {*} value The value to search for.
191    * @param {number} [fromIndex=0] The index to search from.
192    * @returns {number} Returns the index of the matched value or `-1`.
193    */
194   function baseIndexOf(array, value, fromIndex) {
195     var index = (fromIndex || 0) - 1,
196         length = array ? array.length : 0;
197
198     while (++index < length) {
199       if (array[index] === value) {
200         return index;
201       }
202     }
203     return -1;
204   }
205
206   /**
207    * An implementation of `_.contains` for cache objects that mimics the return
208    * signature of `_.indexOf` by returning `0` if the value is found, else `-1`.
209    *
210    * @private
211    * @param {Object} cache The cache object to inspect.
212    * @param {*} value The value to search for.
213    * @returns {number} Returns `0` if `value` is found, else `-1`.
214    */
215   function cacheIndexOf(cache, value) {
216     var type = typeof value;
217     cache = cache.cache;
218
219     if (type == 'boolean' || value == null) {
220       return cache[value] ? 0 : -1;
221     }
222     if (type != 'number' && type != 'string') {
223       type = 'object';
224     }
225     var key = type == 'number' ? value : keyPrefix + value;
226     cache = (cache = cache[type]) && cache[key];
227
228     return type == 'object'
229       ? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1)
230       : (cache ? 0 : -1);
231   }
232
233   /**
234    * Adds a given value to the corresponding cache object.
235    *
236    * @private
237    * @param {*} value The value to add to the cache.
238    */
239   function cachePush(value) {
240     var cache = this.cache,
241         type = typeof value;
242
243     if (type == 'boolean' || value == null) {
244       cache[value] = true;
245     } else {
246       if (type != 'number' && type != 'string') {
247         type = 'object';
248       }
249       var key = type == 'number' ? value : keyPrefix + value,
250           typeCache = cache[type] || (cache[type] = {});
251
252       if (type == 'object') {
253         (typeCache[key] || (typeCache[key] = [])).push(value);
254       } else {
255         typeCache[key] = true;
256       }
257     }
258   }
259
260   /**
261    * Used by `_.max` and `_.min` as the default callback when a given
262    * collection is a string value.
263    *
264    * @private
265    * @param {string} value The character to inspect.
266    * @returns {number} Returns the code unit of given character.
267    */
268   function charAtCallback(value) {
269     return value.charCodeAt(0);
270   }
271
272   /**
273    * Used by `sortBy` to compare transformed `collection` elements, stable sorting
274    * them in ascending order.
275    *
276    * @private
277    * @param {Object} a The object to compare to `b`.
278    * @param {Object} b The object to compare to `a`.
279    * @returns {number} Returns the sort order indicator of `1` or `-1`.
280    */
281   function compareAscending(a, b) {
282     var ac = a.criteria,
283         bc = b.criteria,
284         index = -1,
285         length = ac.length;
286
287     while (++index < length) {
288       var value = ac[index],
289           other = bc[index];
290
291       if (value !== other) {
292         if (value > other || typeof value == 'undefined') {
293           return 1;
294         }
295         if (value < other || typeof other == 'undefined') {
296           return -1;
297         }
298       }
299     }
300     // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
301     // that causes it, under certain circumstances, to return the same value for
302     // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247
303     //
304     // This also ensures a stable sort in V8 and other engines.
305     // See http://code.google.com/p/v8/issues/detail?id=90
306     return a.index - b.index;
307   }
308
309   /**
310    * Creates a cache object to optimize linear searches of large arrays.
311    *
312    * @private
313    * @param {Array} [array=[]] The array to search.
314    * @returns {null|Object} Returns the cache object or `null` if caching should not be used.
315    */
316   function createCache(array) {
317     var index = -1,
318         length = array.length,
319         first = array[0],
320         mid = array[(length / 2) | 0],
321         last = array[length - 1];
322
323     if (first && typeof first == 'object' &&
324         mid && typeof mid == 'object' && last && typeof last == 'object') {
325       return false;
326     }
327     var cache = getObject();
328     cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;
329
330     var result = getObject();
331     result.array = array;
332     result.cache = cache;
333     result.push = cachePush;
334
335     while (++index < length) {
336       result.push(array[index]);
337     }
338     return result;
339   }
340
341   /**
342    * Used by `template` to escape characters for inclusion in compiled
343    * string literals.
344    *
345    * @private
346    * @param {string} match The matched character to escape.
347    * @returns {string} Returns the escaped character.
348    */
349   function escapeStringChar(match) {
350     return '\\' + stringEscapes[match];
351   }
352
353   /**
354    * Gets an array from the array pool or creates a new one if the pool is empty.
355    *
356    * @private
357    * @returns {Array} The array from the pool.
358    */
359   function getArray() {
360     return arrayPool.pop() || [];
361   }
362
363   /**
364    * Gets an object from the object pool or creates a new one if the pool is empty.
365    *
366    * @private
367    * @returns {Object} The object from the pool.
368    */
369   function getObject() {
370     return objectPool.pop() || {
371       'array': null,
372       'cache': null,
373       'criteria': null,
374       'false': false,
375       'index': 0,
376       'null': false,
377       'number': null,
378       'object': null,
379       'push': null,
380       'string': null,
381       'true': false,
382       'undefined': false,
383       'value': null
384     };
385   }
386
387   /**
388    * Checks if `value` is a DOM node in IE < 9.
389    *
390    * @private
391    * @param {*} value The value to check.
392    * @returns {boolean} Returns `true` if the `value` is a DOM node, else `false`.
393    */
394   function isNode(value) {
395     // IE < 9 presents DOM nodes as `Object` objects except they have `toString`
396     // methods that are `typeof` "string" and still can coerce nodes to strings
397     return typeof value.toString != 'function' && typeof (value + '') == 'string';
398   }
399
400   /**
401    * Releases the given array back to the array pool.
402    *
403    * @private
404    * @param {Array} [array] The array to release.
405    */
406   function releaseArray(array) {
407     array.length = 0;
408     if (arrayPool.length < maxPoolSize) {
409       arrayPool.push(array);
410     }
411   }
412
413   /**
414    * Releases the given object back to the object pool.
415    *
416    * @private
417    * @param {Object} [object] The object to release.
418    */
419   function releaseObject(object) {
420     var cache = object.cache;
421     if (cache) {
422       releaseObject(cache);
423     }
424     object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
425     if (objectPool.length < maxPoolSize) {
426       objectPool.push(object);
427     }
428   }
429
430   /**
431    * Slices the `collection` from the `start` index up to, but not including,
432    * the `end` index.
433    *
434    * Note: This function is used instead of `Array#slice` to support node lists
435    * in IE < 9 and to ensure dense arrays are returned.
436    *
437    * @private
438    * @param {Array|Object|string} collection The collection to slice.
439    * @param {number} start The start index.
440    * @param {number} end The end index.
441    * @returns {Array} Returns the new array.
442    */
443   function slice(array, start, end) {
444     start || (start = 0);
445     if (typeof end == 'undefined') {
446       end = array ? array.length : 0;
447     }
448     var index = -1,
449         length = end - start || 0,
450         result = Array(length < 0 ? 0 : length);
451
452     while (++index < length) {
453       result[index] = array[start + index];
454     }
455     return result;
456   }
457
458   /*--------------------------------------------------------------------------*/
459
460   /**
461    * Create a new `lodash` function using the given context object.
462    *
463    * @static
464    * @memberOf _
465    * @category Utilities
466    * @param {Object} [context=root] The context object.
467    * @returns {Function} Returns the `lodash` function.
468    */
469   function runInContext(context) {
470     // Avoid issues with some ES3 environments that attempt to use values, named
471     // after built-in constructors like `Object`, for the creation of literals.
472     // ES5 clears this up by stating that literals must use built-in constructors.
473     // See http://es5.github.io/#x11.1.5.
474     context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
475
476     /** Native constructor references */
477     var Array = context.Array,
478         Boolean = context.Boolean,
479         Date = context.Date,
480         Error = context.Error,
481         Function = context.Function,
482         Math = context.Math,
483         Number = context.Number,
484         Object = context.Object,
485         RegExp = context.RegExp,
486         String = context.String,
487         TypeError = context.TypeError;
488
489     /**
490      * Used for `Array` method references.
491      *
492      * Normally `Array.prototype` would suffice, however, using an array literal
493      * avoids issues in Narwhal.
494      */
495     var arrayRef = [];
496
497     /** Used for native method references */
498     var errorProto = Error.prototype,
499         objectProto = Object.prototype,
500         stringProto = String.prototype;
501
502     /** Used to restore the original `_` reference in `noConflict` */
503     var oldDash = context._;
504
505     /** Used to resolve the internal [[Class]] of values */
506     var toString = objectProto.toString;
507
508     /** Used to detect if a method is native */
509     var reNative = RegExp('^' +
510       String(toString)
511         .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
512         .replace(/toString| for [^\]]+/g, '.*?') + '$'
513     );
514
515     /** Native method shortcuts */
516     var ceil = Math.ceil,
517         clearTimeout = context.clearTimeout,
518         floor = Math.floor,
519         fnToString = Function.prototype.toString,
520         getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
521         hasOwnProperty = objectProto.hasOwnProperty,
522         push = arrayRef.push,
523         propertyIsEnumerable = objectProto.propertyIsEnumerable,
524         setTimeout = context.setTimeout,
525         splice = arrayRef.splice,
526         unshift = arrayRef.unshift;
527
528     /** Used to set meta data on functions */
529     var defineProperty = (function() {
530       // IE 8 only accepts DOM elements
531       try {
532         var o = {},
533             func = isNative(func = Object.defineProperty) && func,
534             result = func(o, o, o) && func;
535       } catch(e) { }
536       return result;
537     }());
538
539     /* Native method shortcuts for methods with the same name as other `lodash` methods */
540     var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate,
541         nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
542         nativeIsFinite = context.isFinite,
543         nativeIsNaN = context.isNaN,
544         nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
545         nativeMax = Math.max,
546         nativeMin = Math.min,
547         nativeParseInt = context.parseInt,
548         nativeRandom = Math.random;
549
550     /** Used to lookup a built-in constructor by [[Class]] */
551     var ctorByClass = {};
552     ctorByClass[arrayClass] = Array;
553     ctorByClass[boolClass] = Boolean;
554     ctorByClass[dateClass] = Date;
555     ctorByClass[funcClass] = Function;
556     ctorByClass[objectClass] = Object;
557     ctorByClass[numberClass] = Number;
558     ctorByClass[regexpClass] = RegExp;
559     ctorByClass[stringClass] = String;
560
561     /** Used to avoid iterating non-enumerable properties in IE < 9 */
562     var nonEnumProps = {};
563     nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };
564     nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true };
565     nonEnumProps[errorClass] = nonEnumProps[funcClass] = nonEnumProps[regexpClass] = { 'constructor': true, 'toString': true };
566     nonEnumProps[objectClass] = { 'constructor': true };
567
568     (function() {
569       var length = shadowedProps.length;
570       while (length--) {
571         var key = shadowedProps[length];
572         for (var className in nonEnumProps) {
573           if (hasOwnProperty.call(nonEnumProps, className) && !hasOwnProperty.call(nonEnumProps[className], key)) {
574             nonEnumProps[className][key] = false;
575           }
576         }
577       }
578     }());
579
580     /*--------------------------------------------------------------------------*/
581
582     /**
583      * Creates a `lodash` object which wraps the given value to enable intuitive
584      * method chaining.
585      *
586      * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
587      * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
588      * and `unshift`
589      *
590      * Chaining is supported in custom builds as long as the `value` method is
591      * implicitly or explicitly included in the build.
592      *
593      * The chainable wrapper functions are:
594      * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
595      * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
596      * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
597      * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
598      * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
599      * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
600      * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
601      * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
602      * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
603      * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
604      * and `zip`
605      *
606      * The non-chainable wrapper functions are:
607      * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
608      * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`,
609      * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
610      * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`,
611      * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`,
612      * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`,
613      * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`,
614      * `template`, `unescape`, `uniqueId`, and `value`
615      *
616      * The wrapper functions `first` and `last` return wrapped values when `n` is
617      * provided, otherwise they return unwrapped values.
618      *
619      * Explicit chaining can be enabled by using the `_.chain` method.
620      *
621      * @name _
622      * @constructor
623      * @category Chaining
624      * @param {*} value The value to wrap in a `lodash` instance.
625      * @returns {Object} Returns a `lodash` instance.
626      * @example
627      *
628      * var wrapped = _([1, 2, 3]);
629      *
630      * // returns an unwrapped value
631      * wrapped.reduce(function(sum, num) {
632      *   return sum + num;
633      * });
634      * // => 6
635      *
636      * // returns a wrapped value
637      * var squares = wrapped.map(function(num) {
638      *   return num * num;
639      * });
640      *
641      * _.isArray(squares);
642      * // => false
643      *
644      * _.isArray(squares.value());
645      * // => true
646      */
647     function lodash(value) {
648       // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
649       return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
650        ? value
651        : new lodashWrapper(value);
652     }
653
654     /**
655      * A fast path for creating `lodash` wrapper objects.
656      *
657      * @private
658      * @param {*} value The value to wrap in a `lodash` instance.
659      * @param {boolean} chainAll A flag to enable chaining for all methods
660      * @returns {Object} Returns a `lodash` instance.
661      */
662     function lodashWrapper(value, chainAll) {
663       this.__chain__ = !!chainAll;
664       this.__wrapped__ = value;
665     }
666     // ensure `new lodashWrapper` is an instance of `lodash`
667     lodashWrapper.prototype = lodash.prototype;
668
669     /**
670      * An object used to flag environments features.
671      *
672      * @static
673      * @memberOf _
674      * @type Object
675      */
676     var support = lodash.support = {};
677
678     (function() {
679       var ctor = function() { this.x = 1; },
680           object = { '0': 1, 'length': 1 },
681           props = [];
682
683       ctor.prototype = { 'valueOf': 1, 'y': 1 };
684       for (var key in new ctor) { props.push(key); }
685       for (key in arguments) { }
686
687       /**
688        * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9).
689        *
690        * @memberOf _.support
691        * @type boolean
692        */
693       support.argsClass = toString.call(arguments) == argsClass;
694
695       /**
696        * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5).
697        *
698        * @memberOf _.support
699        * @type boolean
700        */
701       support.argsObject = arguments.constructor == Object && !(arguments instanceof Array);
702
703       /**
704        * Detect if `name` or `message` properties of `Error.prototype` are
705        * enumerable by default. (IE < 9, Safari < 5.1)
706        *
707        * @memberOf _.support
708        * @type boolean
709        */
710       support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') || propertyIsEnumerable.call(errorProto, 'name');
711
712       /**
713        * Detect if `prototype` properties are enumerable by default.
714        *
715        * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
716        * (if the prototype or a property on the prototype has been set)
717        * incorrectly sets a function's `prototype` property [[Enumerable]]
718        * value to `true`.
719        *
720        * @memberOf _.support
721        * @type boolean
722        */
723       support.enumPrototypes = propertyIsEnumerable.call(ctor, 'prototype');
724
725       /**
726        * Detect if functions can be decompiled by `Function#toString`
727        * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
728        *
729        * @memberOf _.support
730        * @type boolean
731        */
732       support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext);
733
734       /**
735        * Detect if `Function#name` is supported (all but IE).
736        *
737        * @memberOf _.support
738        * @type boolean
739        */
740       support.funcNames = typeof Function.name == 'string';
741
742       /**
743        * Detect if `arguments` object indexes are non-enumerable
744        * (Firefox < 4, IE < 9, PhantomJS, Safari < 5.1).
745        *
746        * @memberOf _.support
747        * @type boolean
748        */
749       support.nonEnumArgs = key != 0;
750
751       /**
752        * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
753        *
754        * In IE < 9 an objects own properties, shadowing non-enumerable ones, are
755        * made non-enumerable as well (a.k.a the JScript [[DontEnum]] bug).
756        *
757        * @memberOf _.support
758        * @type boolean
759        */
760       support.nonEnumShadows = !/valueOf/.test(props);
761
762       /**
763        * Detect if own properties are iterated after inherited properties (all but IE < 9).
764        *
765        * @memberOf _.support
766        * @type boolean
767        */
768       support.ownLast = props[0] != 'x';
769
770       /**
771        * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
772        *
773        * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()`
774        * and `splice()` functions that fail to remove the last element, `value[0]`,
775        * of array-like objects even though the `length` property is set to `0`.
776        * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`
777        * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.
778        *
779        * @memberOf _.support
780        * @type boolean
781        */
782       support.spliceObjects = (arrayRef.splice.call(object, 0, 1), !object[0]);
783
784       /**
785        * Detect lack of support for accessing string characters by index.
786        *
787        * IE < 8 can't access characters by index and IE 8 can only access
788        * characters by index on string literals.
789        *
790        * @memberOf _.support
791        * @type boolean
792        */
793       support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
794
795       /**
796        * Detect if a DOM node's [[Class]] is resolvable (all but IE < 9)
797        * and that the JS engine errors when attempting to coerce an object to
798        * a string without a `toString` function.
799        *
800        * @memberOf _.support
801        * @type boolean
802        */
803       try {
804         support.nodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + ''));
805       } catch(e) {
806         support.nodeClass = true;
807       }
808     }(1));
809
810     /**
811      * By default, the template delimiters used by Lo-Dash are similar to those in
812      * embedded Ruby (ERB). Change the following template settings to use alternative
813      * delimiters.
814      *
815      * @static
816      * @memberOf _
817      * @type Object
818      */
819     lodash.templateSettings = {
820
821       /**
822        * Used to detect `data` property values to be HTML-escaped.
823        *
824        * @memberOf _.templateSettings
825        * @type RegExp
826        */
827       'escape': /<%-([\s\S]+?)%>/g,
828
829       /**
830        * Used to detect code to be evaluated.
831        *
832        * @memberOf _.templateSettings
833        * @type RegExp
834        */
835       'evaluate': /<%([\s\S]+?)%>/g,
836
837       /**
838        * Used to detect `data` property values to inject.
839        *
840        * @memberOf _.templateSettings
841        * @type RegExp
842        */
843       'interpolate': reInterpolate,
844
845       /**
846        * Used to reference the data object in the template text.
847        *
848        * @memberOf _.templateSettings
849        * @type string
850        */
851       'variable': '',
852
853       /**
854        * Used to import variables into the compiled template.
855        *
856        * @memberOf _.templateSettings
857        * @type Object
858        */
859       'imports': {
860
861         /**
862          * A reference to the `lodash` function.
863          *
864          * @memberOf _.templateSettings.imports
865          * @type Function
866          */
867         '_': lodash
868       }
869     };
870
871     /*--------------------------------------------------------------------------*/
872
873     /**
874      * The template used to create iterator functions.
875      *
876      * @private
877      * @param {Object} data The data object used to populate the text.
878      * @returns {string} Returns the interpolated text.
879      */
880     var iteratorTemplate = template(
881       // the `iterable` may be reassigned by the `top` snippet
882       'var index, iterable = <%= firstArg %>, ' +
883       // assign the `result` variable an initial value
884       'result = <%= init %>;\n' +
885       // exit early if the first argument is falsey
886       'if (!iterable) return result;\n' +
887       // add code before the iteration branches
888       '<%= top %>;' +
889
890       // array-like iteration:
891       '<% if (array) { %>\n' +
892       'var length = iterable.length; index = -1;\n' +
893       'if (<%= array %>) {' +
894
895       // add support for accessing string characters by index if needed
896       '  <% if (support.unindexedChars) { %>\n' +
897       '  if (isString(iterable)) {\n' +
898       "    iterable = iterable.split('')\n" +
899       '  }' +
900       '  <% } %>\n' +
901
902       // iterate over the array-like value
903       '  while (++index < length) {\n' +
904       '    <%= loop %>;\n' +
905       '  }\n' +
906       '}\n' +
907       'else {' +
908
909       // object iteration:
910       // add support for iterating over `arguments` objects if needed
911       '  <% } else if (support.nonEnumArgs) { %>\n' +
912       '  var length = iterable.length; index = -1;\n' +
913       '  if (length && isArguments(iterable)) {\n' +
914       '    while (++index < length) {\n' +
915       "      index += '';\n" +
916       '      <%= loop %>;\n' +
917       '    }\n' +
918       '  } else {' +
919       '  <% } %>' +
920
921       // avoid iterating over `prototype` properties in older Firefox, Opera, and Safari
922       '  <% if (support.enumPrototypes) { %>\n' +
923       "  var skipProto = typeof iterable == 'function';\n" +
924       '  <% } %>' +
925
926       // avoid iterating over `Error.prototype` properties in older IE and Safari
927       '  <% if (support.enumErrorProps) { %>\n' +
928       '  var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n' +
929       '  <% } %>' +
930
931       // define conditions used in the loop
932       '  <%' +
933       '    var conditions = [];' +
934       '    if (support.enumPrototypes) { conditions.push(\'!(skipProto && index == "prototype")\'); }' +
935       '    if (support.enumErrorProps)  { conditions.push(\'!(skipErrorProps && (index == "message" || index == "name"))\'); }' +
936       '  %>' +
937
938       // iterate own properties using `Object.keys`
939       '  <% if (useHas && keys) { %>\n' +
940       '  var ownIndex = -1,\n' +
941       '      ownProps = objectTypes[typeof iterable] && keys(iterable),\n' +
942       '      length = ownProps ? ownProps.length : 0;\n\n' +
943       '  while (++ownIndex < length) {\n' +
944       '    index = ownProps[ownIndex];\n<%' +
945       "    if (conditions.length) { %>    if (<%= conditions.join(' && ') %>) {\n  <% } %>" +
946       '    <%= loop %>;' +
947       '    <% if (conditions.length) { %>\n    }<% } %>\n' +
948       '  }' +
949
950       // else using a for-in loop
951       '  <% } else { %>\n' +
952       '  for (index in iterable) {\n<%' +
953       '    if (useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); }' +
954       "    if (conditions.length) { %>    if (<%= conditions.join(' && ') %>) {\n  <% } %>" +
955       '    <%= loop %>;' +
956       '    <% if (conditions.length) { %>\n    }<% } %>\n' +
957       '  }' +
958
959       // Because IE < 9 can't set the `[[Enumerable]]` attribute of an
960       // existing property and the `constructor` property of a prototype
961       // defaults to non-enumerable, Lo-Dash skips the `constructor`
962       // property when it infers it's iterating over a `prototype` object.
963       '    <% if (support.nonEnumShadows) { %>\n\n' +
964       '  if (iterable !== objectProto) {\n' +
965       "    var ctor = iterable.constructor,\n" +
966       '        isProto = iterable === (ctor && ctor.prototype),\n' +
967       '        className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n' +
968       '        nonEnum = nonEnumProps[className];\n' +
969       '      <% for (k = 0; k < 7; k++) { %>\n' +
970       "    index = '<%= shadowedProps[k] %>';\n" +
971       '    if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))<%' +
972       '        if (!useHas) { %> || (!nonEnum[index] && iterable[index] !== objectProto[index])<% }' +
973       '      %>) {\n' +
974       '      <%= loop %>;\n' +
975       '    }' +
976       '      <% } %>\n' +
977       '  }' +
978       '    <% } %>' +
979       '  <% } %>' +
980       '  <% if (array || support.nonEnumArgs) { %>\n}<% } %>\n' +
981
982       // add code to the bottom of the iteration function
983       '<%= bottom %>;\n' +
984       // finally, return the `result`
985       'return result'
986     );
987
988     /*--------------------------------------------------------------------------*/
989
990     /**
991      * The base implementation of `_.bind` that creates the bound function and
992      * sets its meta data.
993      *
994      * @private
995      * @param {Array} bindData The bind data array.
996      * @returns {Function} Returns the new bound function.
997      */
998     function baseBind(bindData) {
999       var func = bindData[0],
1000           partialArgs = bindData[2],
1001           thisArg = bindData[4];
1002
1003       function bound() {
1004         // `Function#bind` spec
1005         // http://es5.github.io/#x15.3.4.5
1006         if (partialArgs) {
1007           // avoid `arguments` object deoptimizations by using `slice` instead
1008           // of `Array.prototype.slice.call` and not assigning `arguments` to a
1009           // variable as a ternary expression
1010           var args = slice(partialArgs);
1011           push.apply(args, arguments);
1012         }
1013         // mimic the constructor's `return` behavior
1014         // http://es5.github.io/#x13.2.2
1015         if (this instanceof bound) {
1016           // ensure `new bound` is an instance of `func`
1017           var thisBinding = baseCreate(func.prototype),
1018               result = func.apply(thisBinding, args || arguments);
1019           return isObject(result) ? result : thisBinding;
1020         }
1021         return func.apply(thisArg, args || arguments);
1022       }
1023       setBindData(bound, bindData);
1024       return bound;
1025     }
1026
1027     /**
1028      * The base implementation of `_.clone` without argument juggling or support
1029      * for `thisArg` binding.
1030      *
1031      * @private
1032      * @param {*} value The value to clone.
1033      * @param {boolean} [isDeep=false] Specify a deep clone.
1034      * @param {Function} [callback] The function to customize cloning values.
1035      * @param {Array} [stackA=[]] Tracks traversed source objects.
1036      * @param {Array} [stackB=[]] Associates clones with source counterparts.
1037      * @returns {*} Returns the cloned value.
1038      */
1039     function baseClone(value, isDeep, callback, stackA, stackB) {
1040       if (callback) {
1041         var result = callback(value);
1042         if (typeof result != 'undefined') {
1043           return result;
1044         }
1045       }
1046       // inspect [[Class]]
1047       var isObj = isObject(value);
1048       if (isObj) {
1049         var className = toString.call(value);
1050         if (!cloneableClasses[className] || (!support.nodeClass && isNode(value))) {
1051           return value;
1052         }
1053         var ctor = ctorByClass[className];
1054         switch (className) {
1055           case boolClass:
1056           case dateClass:
1057             return new ctor(+value);
1058
1059           case numberClass:
1060           case stringClass:
1061             return new ctor(value);
1062
1063           case regexpClass:
1064             result = ctor(value.source, reFlags.exec(value));
1065             result.lastIndex = value.lastIndex;
1066             return result;
1067         }
1068       } else {
1069         return value;
1070       }
1071       var isArr = isArray(value);
1072       if (isDeep) {
1073         // check for circular references and return corresponding clone
1074         var initedStack = !stackA;
1075         stackA || (stackA = getArray());
1076         stackB || (stackB = getArray());
1077
1078         var length = stackA.length;
1079         while (length--) {
1080           if (stackA[length] == value) {
1081             return stackB[length];
1082           }
1083         }
1084         result = isArr ? ctor(value.length) : {};
1085       }
1086       else {
1087         result = isArr ? slice(value) : assign({}, value);
1088       }
1089       // add array properties assigned by `RegExp#exec`
1090       if (isArr) {
1091         if (hasOwnProperty.call(value, 'index')) {
1092           result.index = value.index;
1093         }
1094         if (hasOwnProperty.call(value, 'input')) {
1095           result.input = value.input;
1096         }
1097       }
1098       // exit for shallow clone
1099       if (!isDeep) {
1100         return result;
1101       }
1102       // add the source value to the stack of traversed objects
1103       // and associate it with its clone
1104       stackA.push(value);
1105       stackB.push(result);
1106
1107       // recursively populate clone (susceptible to call stack limits)
1108       (isArr ? baseEach : forOwn)(value, function(objValue, key) {
1109         result[key] = baseClone(objValue, isDeep, callback, stackA, stackB);
1110       });
1111
1112       if (initedStack) {
1113         releaseArray(stackA);
1114         releaseArray(stackB);
1115       }
1116       return result;
1117     }
1118
1119     /**
1120      * The base implementation of `_.create` without support for assigning
1121      * properties to the created object.
1122      *
1123      * @private
1124      * @param {Object} prototype The object to inherit from.
1125      * @returns {Object} Returns the new object.
1126      */
1127     function baseCreate(prototype, properties) {
1128       return isObject(prototype) ? nativeCreate(prototype) : {};
1129     }
1130     // fallback for browsers without `Object.create`
1131     if (!nativeCreate) {
1132       baseCreate = (function() {
1133         function Object() {}
1134         return function(prototype) {
1135           if (isObject(prototype)) {
1136             Object.prototype = prototype;
1137             var result = new Object;
1138             Object.prototype = null;
1139           }
1140           return result || context.Object();
1141         };
1142       }());
1143     }
1144
1145     /**
1146      * The base implementation of `_.createCallback` without support for creating
1147      * "_.pluck" or "_.where" style callbacks.
1148      *
1149      * @private
1150      * @param {*} [func=identity] The value to convert to a callback.
1151      * @param {*} [thisArg] The `this` binding of the created callback.
1152      * @param {number} [argCount] The number of arguments the callback accepts.
1153      * @returns {Function} Returns a callback function.
1154      */
1155     function baseCreateCallback(func, thisArg, argCount) {
1156       if (typeof func != 'function') {
1157         return identity;
1158       }
1159       // exit early for no `thisArg` or already bound by `Function#bind`
1160       if (typeof thisArg == 'undefined' || !('prototype' in func)) {
1161         return func;
1162       }
1163       var bindData = func.__bindData__;
1164       if (typeof bindData == 'undefined') {
1165         if (support.funcNames) {
1166           bindData = !func.name;
1167         }
1168         bindData = bindData || !support.funcDecomp;
1169         if (!bindData) {
1170           var source = fnToString.call(func);
1171           if (!support.funcNames) {
1172             bindData = !reFuncName.test(source);
1173           }
1174           if (!bindData) {
1175             // checks if `func` references the `this` keyword and stores the result
1176             bindData = reThis.test(source);
1177             setBindData(func, bindData);
1178           }
1179         }
1180       }
1181       // exit early if there are no `this` references or `func` is bound
1182       if (bindData === false || (bindData !== true && bindData[1] & 1)) {
1183         return func;
1184       }
1185       switch (argCount) {
1186         case 1: return function(value) {
1187           return func.call(thisArg, value);
1188         };
1189         case 2: return function(a, b) {
1190           return func.call(thisArg, a, b);
1191         };
1192         case 3: return function(value, index, collection) {
1193           return func.call(thisArg, value, index, collection);
1194         };
1195         case 4: return function(accumulator, value, index, collection) {
1196           return func.call(thisArg, accumulator, value, index, collection);
1197         };
1198       }
1199       return bind(func, thisArg);
1200     }
1201
1202     /**
1203      * The base implementation of `createWrapper` that creates the wrapper and
1204      * sets its meta data.
1205      *
1206      * @private
1207      * @param {Array} bindData The bind data array.
1208      * @returns {Function} Returns the new function.
1209      */
1210     function baseCreateWrapper(bindData) {
1211       var func = bindData[0],
1212           bitmask = bindData[1],
1213           partialArgs = bindData[2],
1214           partialRightArgs = bindData[3],
1215           thisArg = bindData[4],
1216           arity = bindData[5];
1217
1218       var isBind = bitmask & 1,
1219           isBindKey = bitmask & 2,
1220           isCurry = bitmask & 4,
1221           isCurryBound = bitmask & 8,
1222           key = func;
1223
1224       function bound() {
1225         var thisBinding = isBind ? thisArg : this;
1226         if (partialArgs) {
1227           var args = slice(partialArgs);
1228           push.apply(args, arguments);
1229         }
1230         if (partialRightArgs || isCurry) {
1231           args || (args = slice(arguments));
1232           if (partialRightArgs) {
1233             push.apply(args, partialRightArgs);
1234           }
1235           if (isCurry && args.length < arity) {
1236             bitmask |= 16 & ~32;
1237             return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]);
1238           }
1239         }
1240         args || (args = arguments);
1241         if (isBindKey) {
1242           func = thisBinding[key];
1243         }
1244         if (this instanceof bound) {
1245           thisBinding = baseCreate(func.prototype);
1246           var result = func.apply(thisBinding, args);
1247           return isObject(result) ? result : thisBinding;
1248         }
1249         return func.apply(thisBinding, args);
1250       }
1251       setBindData(bound, bindData);
1252       return bound;
1253     }
1254
1255     /**
1256      * The base implementation of `_.difference` that accepts a single array
1257      * of values to exclude.
1258      *
1259      * @private
1260      * @param {Array} array The array to process.
1261      * @param {Array} [values] The array of values to exclude.
1262      * @returns {Array} Returns a new array of filtered values.
1263      */
1264     function baseDifference(array, values) {
1265       var index = -1,
1266           indexOf = getIndexOf(),
1267           length = array ? array.length : 0,
1268           isLarge = length >= largeArraySize && indexOf === baseIndexOf,
1269           result = [];
1270
1271       if (isLarge) {
1272         var cache = createCache(values);
1273         if (cache) {
1274           indexOf = cacheIndexOf;
1275           values = cache;
1276         } else {
1277           isLarge = false;
1278         }
1279       }
1280       while (++index < length) {
1281         var value = array[index];
1282         if (indexOf(values, value) < 0) {
1283           result.push(value);
1284         }
1285       }
1286       if (isLarge) {
1287         releaseObject(values);
1288       }
1289       return result;
1290     }
1291
1292     /**
1293      * The base implementation of `_.flatten` without support for callback
1294      * shorthands or `thisArg` binding.
1295      *
1296      * @private
1297      * @param {Array} array The array to flatten.
1298      * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
1299      * @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects.
1300      * @param {number} [fromIndex=0] The index to start from.
1301      * @returns {Array} Returns a new flattened array.
1302      */
1303     function baseFlatten(array, isShallow, isStrict, fromIndex) {
1304       var index = (fromIndex || 0) - 1,
1305           length = array ? array.length : 0,
1306           result = [];
1307
1308       while (++index < length) {
1309         var value = array[index];
1310
1311         if (value && typeof value == 'object' && typeof value.length == 'number'
1312             && (isArray(value) || isArguments(value))) {
1313           // recursively flatten arrays (susceptible to call stack limits)
1314           if (!isShallow) {
1315             value = baseFlatten(value, isShallow, isStrict);
1316           }
1317           var valIndex = -1,
1318               valLength = value.length,
1319               resIndex = result.length;
1320
1321           result.length += valLength;
1322           while (++valIndex < valLength) {
1323             result[resIndex++] = value[valIndex];
1324           }
1325         } else if (!isStrict) {
1326           result.push(value);
1327         }
1328       }
1329       return result;
1330     }
1331
1332     /**
1333      * The base implementation of `_.isEqual`, without support for `thisArg` binding,
1334      * that allows partial "_.where" style comparisons.
1335      *
1336      * @private
1337      * @param {*} a The value to compare.
1338      * @param {*} b The other value to compare.
1339      * @param {Function} [callback] The function to customize comparing values.
1340      * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons.
1341      * @param {Array} [stackA=[]] Tracks traversed `a` objects.
1342      * @param {Array} [stackB=[]] Tracks traversed `b` objects.
1343      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1344      */
1345     function baseIsEqual(a, b, callback, isWhere, stackA, stackB) {
1346       // used to indicate that when comparing objects, `a` has at least the properties of `b`
1347       if (callback) {
1348         var result = callback(a, b);
1349         if (typeof result != 'undefined') {
1350           return !!result;
1351         }
1352       }
1353       // exit early for identical values
1354       if (a === b) {
1355         // treat `+0` vs. `-0` as not equal
1356         return a !== 0 || (1 / a == 1 / b);
1357       }
1358       var type = typeof a,
1359           otherType = typeof b;
1360
1361       // exit early for unlike primitive values
1362       if (a === a &&
1363           !(a && objectTypes[type]) &&
1364           !(b && objectTypes[otherType])) {
1365         return false;
1366       }
1367       // exit early for `null` and `undefined` avoiding ES3's Function#call behavior
1368       // http://es5.github.io/#x15.3.4.4
1369       if (a == null || b == null) {
1370         return a === b;
1371       }
1372       // compare [[Class]] names
1373       var className = toString.call(a),
1374           otherClass = toString.call(b);
1375
1376       if (className == argsClass) {
1377         className = objectClass;
1378       }
1379       if (otherClass == argsClass) {
1380         otherClass = objectClass;
1381       }
1382       if (className != otherClass) {
1383         return false;
1384       }
1385       switch (className) {
1386         case boolClass:
1387         case dateClass:
1388           // coerce dates and booleans to numbers, dates to milliseconds and booleans
1389           // to `1` or `0` treating invalid dates coerced to `NaN` as not equal
1390           return +a == +b;
1391
1392         case numberClass:
1393           // treat `NaN` vs. `NaN` as equal
1394           return (a != +a)
1395             ? b != +b
1396             // but treat `+0` vs. `-0` as not equal
1397             : (a == 0 ? (1 / a == 1 / b) : a == +b);
1398
1399         case regexpClass:
1400         case stringClass:
1401           // coerce regexes to strings (http://es5.github.io/#x15.10.6.4)
1402           // treat string primitives and their corresponding object instances as equal
1403           return a == String(b);
1404       }
1405       var isArr = className == arrayClass;
1406       if (!isArr) {
1407         // unwrap any `lodash` wrapped values
1408         var aWrapped = hasOwnProperty.call(a, '__wrapped__'),
1409             bWrapped = hasOwnProperty.call(b, '__wrapped__');
1410
1411         if (aWrapped || bWrapped) {
1412           return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, callback, isWhere, stackA, stackB);
1413         }
1414         // exit for functions and DOM nodes
1415         if (className != objectClass || (!support.nodeClass && (isNode(a) || isNode(b)))) {
1416           return false;
1417         }
1418         // in older versions of Opera, `arguments` objects have `Array` constructors
1419         var ctorA = !support.argsObject && isArguments(a) ? Object : a.constructor,
1420             ctorB = !support.argsObject && isArguments(b) ? Object : b.constructor;
1421
1422         // non `Object` object instances with different constructors are not equal
1423         if (ctorA != ctorB &&
1424               !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) &&
1425               ('constructor' in a && 'constructor' in b)
1426             ) {
1427           return false;
1428         }
1429       }
1430       // assume cyclic structures are equal
1431       // the algorithm for detecting cyclic structures is adapted from ES 5.1
1432       // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3)
1433       var initedStack = !stackA;
1434       stackA || (stackA = getArray());
1435       stackB || (stackB = getArray());
1436
1437       var length = stackA.length;
1438       while (length--) {
1439         if (stackA[length] == a) {
1440           return stackB[length] == b;
1441         }
1442       }
1443       var size = 0;
1444       result = true;
1445
1446       // add `a` and `b` to the stack of traversed objects
1447       stackA.push(a);
1448       stackB.push(b);
1449
1450       // recursively compare objects and arrays (susceptible to call stack limits)
1451       if (isArr) {
1452         // compare lengths to determine if a deep comparison is necessary
1453         length = a.length;
1454         size = b.length;
1455         result = size == length;
1456
1457         if (result || isWhere) {
1458           // deep compare the contents, ignoring non-numeric properties
1459           while (size--) {
1460             var index = length,
1461                 value = b[size];
1462
1463             if (isWhere) {
1464               while (index--) {
1465                 if ((result = baseIsEqual(a[index], value, callback, isWhere, stackA, stackB))) {
1466                   break;
1467                 }
1468               }
1469             } else if (!(result = baseIsEqual(a[size], value, callback, isWhere, stackA, stackB))) {
1470               break;
1471             }
1472           }
1473         }
1474       }
1475       else {
1476         // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys`
1477         // which, in this case, is more costly
1478         forIn(b, function(value, key, b) {
1479           if (hasOwnProperty.call(b, key)) {
1480             // count the number of properties.
1481             size++;
1482             // deep compare each property value.
1483             return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, callback, isWhere, stackA, stackB));
1484           }
1485         });
1486
1487         if (result && !isWhere) {
1488           // ensure both objects have the same number of properties
1489           forIn(a, function(value, key, a) {
1490             if (hasOwnProperty.call(a, key)) {
1491               // `size` will be `-1` if `a` has more properties than `b`
1492               return (result = --size > -1);
1493             }
1494           });
1495         }
1496       }
1497       stackA.pop();
1498       stackB.pop();
1499
1500       if (initedStack) {
1501         releaseArray(stackA);
1502         releaseArray(stackB);
1503       }
1504       return result;
1505     }
1506
1507     /**
1508      * The base implementation of `_.merge` without argument juggling or support
1509      * for `thisArg` binding.
1510      *
1511      * @private
1512      * @param {Object} object The destination object.
1513      * @param {Object} source The source object.
1514      * @param {Function} [callback] The function to customize merging properties.
1515      * @param {Array} [stackA=[]] Tracks traversed source objects.
1516      * @param {Array} [stackB=[]] Associates values with source counterparts.
1517      */
1518     function baseMerge(object, source, callback, stackA, stackB) {
1519       (isArray(source) ? forEach : forOwn)(source, function(source, key) {
1520         var found,
1521             isArr,
1522             result = source,
1523             value = object[key];
1524
1525         if (source && ((isArr = isArray(source)) || isPlainObject(source))) {
1526           // avoid merging previously merged cyclic sources
1527           var stackLength = stackA.length;
1528           while (stackLength--) {
1529             if ((found = stackA[stackLength] == source)) {
1530               value = stackB[stackLength];
1531               break;
1532             }
1533           }
1534           if (!found) {
1535             var isShallow;
1536             if (callback) {
1537               result = callback(value, source);
1538               if ((isShallow = typeof result != 'undefined')) {
1539                 value = result;
1540               }
1541             }
1542             if (!isShallow) {
1543               value = isArr
1544                 ? (isArray(value) ? value : [])
1545                 : (isPlainObject(value) ? value : {});
1546             }
1547             // add `source` and associated `value` to the stack of traversed objects
1548             stackA.push(source);
1549             stackB.push(value);
1550
1551             // recursively merge objects and arrays (susceptible to call stack limits)
1552             if (!isShallow) {
1553               baseMerge(value, source, callback, stackA, stackB);
1554             }
1555           }
1556         }
1557         else {
1558           if (callback) {
1559             result = callback(value, source);
1560             if (typeof result == 'undefined') {
1561               result = source;
1562             }
1563           }
1564           if (typeof result != 'undefined') {
1565             value = result;
1566           }
1567         }
1568         object[key] = value;
1569       });
1570     }
1571
1572     /**
1573      * The base implementation of `_.random` without argument juggling or support
1574      * for returning floating-point numbers.
1575      *
1576      * @private
1577      * @param {number} min The minimum possible value.
1578      * @param {number} max The maximum possible value.
1579      * @returns {number} Returns a random number.
1580      */
1581     function baseRandom(min, max) {
1582       return min + floor(nativeRandom() * (max - min + 1));
1583     }
1584
1585     /**
1586      * The base implementation of `_.uniq` without support for callback shorthands
1587      * or `thisArg` binding.
1588      *
1589      * @private
1590      * @param {Array} array The array to process.
1591      * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted.
1592      * @param {Function} [callback] The function called per iteration.
1593      * @returns {Array} Returns a duplicate-value-free array.
1594      */
1595     function baseUniq(array, isSorted, callback) {
1596       var index = -1,
1597           indexOf = getIndexOf(),
1598           length = array ? array.length : 0,
1599           result = [];
1600
1601       var isLarge = !isSorted && length >= largeArraySize && indexOf === baseIndexOf,
1602           seen = (callback || isLarge) ? getArray() : result;
1603
1604       if (isLarge) {
1605         var cache = createCache(seen);
1606         indexOf = cacheIndexOf;
1607         seen = cache;
1608       }
1609       while (++index < length) {
1610         var value = array[index],
1611             computed = callback ? callback(value, index, array) : value;
1612
1613         if (isSorted
1614               ? !index || seen[seen.length - 1] !== computed
1615               : indexOf(seen, computed) < 0
1616             ) {
1617           if (callback || isLarge) {
1618             seen.push(computed);
1619           }
1620           result.push(value);
1621         }
1622       }
1623       if (isLarge) {
1624         releaseArray(seen.array);
1625         releaseObject(seen);
1626       } else if (callback) {
1627         releaseArray(seen);
1628       }
1629       return result;
1630     }
1631
1632     /**
1633      * Creates a function that aggregates a collection, creating an object composed
1634      * of keys generated from the results of running each element of the collection
1635      * through a callback. The given `setter` function sets the keys and values
1636      * of the composed object.
1637      *
1638      * @private
1639      * @param {Function} setter The setter function.
1640      * @returns {Function} Returns the new aggregator function.
1641      */
1642     function createAggregator(setter) {
1643       return function(collection, callback, thisArg) {
1644         var result = {};
1645         callback = lodash.createCallback(callback, thisArg, 3);
1646
1647         if (isArray(collection)) {
1648           var index = -1,
1649               length = collection.length;
1650
1651           while (++index < length) {
1652             var value = collection[index];
1653             setter(result, value, callback(value, index, collection), collection);
1654           }
1655         } else {
1656           baseEach(collection, function(value, key, collection) {
1657             setter(result, value, callback(value, key, collection), collection);
1658           });
1659         }
1660         return result;
1661       };
1662     }
1663
1664     /**
1665      * Creates a function that, when called, either curries or invokes `func`
1666      * with an optional `this` binding and partially applied arguments.
1667      *
1668      * @private
1669      * @param {Function|string} func The function or method name to reference.
1670      * @param {number} bitmask The bitmask of method flags to compose.
1671      *  The bitmask may be composed of the following flags:
1672      *  1 - `_.bind`
1673      *  2 - `_.bindKey`
1674      *  4 - `_.curry`
1675      *  8 - `_.curry` (bound)
1676      *  16 - `_.partial`
1677      *  32 - `_.partialRight`
1678      * @param {Array} [partialArgs] An array of arguments to prepend to those
1679      *  provided to the new function.
1680      * @param {Array} [partialRightArgs] An array of arguments to append to those
1681      *  provided to the new function.
1682      * @param {*} [thisArg] The `this` binding of `func`.
1683      * @param {number} [arity] The arity of `func`.
1684      * @returns {Function} Returns the new function.
1685      */
1686     function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
1687       var isBind = bitmask & 1,
1688           isBindKey = bitmask & 2,
1689           isCurry = bitmask & 4,
1690           isCurryBound = bitmask & 8,
1691           isPartial = bitmask & 16,
1692           isPartialRight = bitmask & 32;
1693
1694       if (!isBindKey && !isFunction(func)) {
1695         throw new TypeError;
1696       }
1697       if (isPartial && !partialArgs.length) {
1698         bitmask &= ~16;
1699         isPartial = partialArgs = false;
1700       }
1701       if (isPartialRight && !partialRightArgs.length) {
1702         bitmask &= ~32;
1703         isPartialRight = partialRightArgs = false;
1704       }
1705       var bindData = func && func.__bindData__;
1706       if (bindData && bindData !== true) {
1707         // clone `bindData`
1708         bindData = slice(bindData);
1709         if (bindData[2]) {
1710           bindData[2] = slice(bindData[2]);
1711         }
1712         if (bindData[3]) {
1713           bindData[3] = slice(bindData[3]);
1714         }
1715         // set `thisBinding` is not previously bound
1716         if (isBind && !(bindData[1] & 1)) {
1717           bindData[4] = thisArg;
1718         }
1719         // set if previously bound but not currently (subsequent curried functions)
1720         if (!isBind && bindData[1] & 1) {
1721           bitmask |= 8;
1722         }
1723         // set curried arity if not yet set
1724         if (isCurry && !(bindData[1] & 4)) {
1725           bindData[5] = arity;
1726         }
1727         // append partial left arguments
1728         if (isPartial) {
1729           push.apply(bindData[2] || (bindData[2] = []), partialArgs);
1730         }
1731         // append partial right arguments
1732         if (isPartialRight) {
1733           unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs);
1734         }
1735         // merge flags
1736         bindData[1] |= bitmask;
1737         return createWrapper.apply(null, bindData);
1738       }
1739       // fast path for `_.bind`
1740       var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper;
1741       return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]);
1742     }
1743
1744     /**
1745      * Creates compiled iteration functions.
1746      *
1747      * @private
1748      * @param {...Object} [options] The compile options object(s).
1749      * @param {string} [options.array] Code to determine if the iterable is an array or array-like.
1750      * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop.
1751      * @param {Function} [options.keys] A reference to `_.keys` for use in own property iteration.
1752      * @param {string} [options.args] A comma separated string of iteration function arguments.
1753      * @param {string} [options.top] Code to execute before the iteration branches.
1754      * @param {string} [options.loop] Code to execute in the object loop.
1755      * @param {string} [options.bottom] Code to execute after the iteration branches.
1756      * @returns {Function} Returns the compiled function.
1757      */
1758     function createIterator() {
1759       // data properties
1760       iteratorData.shadowedProps = shadowedProps;
1761       iteratorData.support = support;
1762
1763       // iterator options
1764       iteratorData.array = iteratorData.bottom = iteratorData.loop = iteratorData.top = '';
1765       iteratorData.init = 'iterable';
1766       iteratorData.useHas = true;
1767
1768       // merge options into a template data object
1769       for (var object, index = 0; object = arguments[index]; index++) {
1770         for (var key in object) {
1771           iteratorData[key] = object[key];
1772         }
1773       }
1774       var args = iteratorData.args;
1775       iteratorData.firstArg = /^[^,]+/.exec(args)[0];
1776
1777       // create the function factory
1778       var factory = Function(
1779           'baseCreateCallback, errorClass, errorProto, hasOwnProperty, ' +
1780           'indicatorObject, isArguments, isArray, isString, keys, objectProto, ' +
1781           'objectTypes, nonEnumProps, stringClass, stringProto, toString',
1782         'return function(' + args + ') {\n' + iteratorTemplate(iteratorData) + '\n}'
1783       );
1784
1785       // return the compiled function
1786       return factory(
1787         baseCreateCallback, errorClass, errorProto, hasOwnProperty,
1788         indicatorObject, isArguments, isArray, isString, iteratorData.keys, objectProto,
1789         objectTypes, nonEnumProps, stringClass, stringProto, toString
1790       );
1791     }
1792
1793     /**
1794      * Used by `escape` to convert characters to HTML entities.
1795      *
1796      * @private
1797      * @param {string} match The matched character to escape.
1798      * @returns {string} Returns the escaped character.
1799      */
1800     function escapeHtmlChar(match) {
1801       return htmlEscapes[match];
1802     }
1803
1804     /**
1805      * Gets the appropriate "indexOf" function. If the `_.indexOf` method is
1806      * customized, this method returns the custom method, otherwise it returns
1807      * the `baseIndexOf` function.
1808      *
1809      * @private
1810      * @returns {Function} Returns the "indexOf" function.
1811      */
1812     function getIndexOf() {
1813       var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result;
1814       return result;
1815     }
1816
1817     /**
1818      * Checks if `value` is a native function.
1819      *
1820      * @private
1821      * @param {*} value The value to check.
1822      * @returns {boolean} Returns `true` if the `value` is a native function, else `false`.
1823      */
1824     function isNative(value) {
1825       return typeof value == 'function' && reNative.test(value);
1826     }
1827
1828     /**
1829      * Sets `this` binding data on a given function.
1830      *
1831      * @private
1832      * @param {Function} func The function to set data on.
1833      * @param {Array} value The data array to set.
1834      */
1835     var setBindData = !defineProperty ? noop : function(func, value) {
1836       descriptor.value = value;
1837       defineProperty(func, '__bindData__', descriptor);
1838       descriptor.value = null;
1839     };
1840
1841     /**
1842      * A fallback implementation of `isPlainObject` which checks if a given value
1843      * is an object created by the `Object` constructor, assuming objects created
1844      * by the `Object` constructor have no inherited enumerable properties and that
1845      * there are no `Object.prototype` extensions.
1846      *
1847      * @private
1848      * @param {*} value The value to check.
1849      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1850      */
1851     function shimIsPlainObject(value) {
1852       var ctor,
1853           result;
1854
1855       // avoid non Object objects, `arguments` objects, and DOM elements
1856       if (!(value && toString.call(value) == objectClass) ||
1857           (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor)) ||
1858           (!support.argsClass && isArguments(value)) ||
1859           (!support.nodeClass && isNode(value))) {
1860         return false;
1861       }
1862       // IE < 9 iterates inherited properties before own properties. If the first
1863       // iterated property is an object's own property then there are no inherited
1864       // enumerable properties.
1865       if (support.ownLast) {
1866         forIn(value, function(value, key, object) {
1867           result = hasOwnProperty.call(object, key);
1868           return false;
1869         });
1870         return result !== false;
1871       }
1872       // In most environments an object's own properties are iterated before
1873       // its inherited properties. If the last iterated property is an object's
1874       // own property then there are no inherited enumerable properties.
1875       forIn(value, function(value, key) {
1876         result = key;
1877       });
1878       return typeof result == 'undefined' || hasOwnProperty.call(value, result);
1879     }
1880
1881     /**
1882      * Used by `unescape` to convert HTML entities to characters.
1883      *
1884      * @private
1885      * @param {string} match The matched character to unescape.
1886      * @returns {string} Returns the unescaped character.
1887      */
1888     function unescapeHtmlChar(match) {
1889       return htmlUnescapes[match];
1890     }
1891
1892     /*--------------------------------------------------------------------------*/
1893
1894     /**
1895      * Checks if `value` is an `arguments` object.
1896      *
1897      * @static
1898      * @memberOf _
1899      * @category Objects
1900      * @param {*} value The value to check.
1901      * @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`.
1902      * @example
1903      *
1904      * (function() { return _.isArguments(arguments); })(1, 2, 3);
1905      * // => true
1906      *
1907      * _.isArguments([1, 2, 3]);
1908      * // => false
1909      */
1910     function isArguments(value) {
1911       return value && typeof value == 'object' && typeof value.length == 'number' &&
1912         toString.call(value) == argsClass || false;
1913     }
1914     // fallback for browsers that can't detect `arguments` objects by [[Class]]
1915     if (!support.argsClass) {
1916       isArguments = function(value) {
1917         return value && typeof value == 'object' && typeof value.length == 'number' &&
1918           hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee') || false;
1919       };
1920     }
1921
1922     /**
1923      * Checks if `value` is an array.
1924      *
1925      * @static
1926      * @memberOf _
1927      * @type Function
1928      * @category Objects
1929      * @param {*} value The value to check.
1930      * @returns {boolean} Returns `true` if the `value` is an array, else `false`.
1931      * @example
1932      *
1933      * (function() { return _.isArray(arguments); })();
1934      * // => false
1935      *
1936      * _.isArray([1, 2, 3]);
1937      * // => true
1938      */
1939     var isArray = nativeIsArray || function(value) {
1940       return value && typeof value == 'object' && typeof value.length == 'number' &&
1941         toString.call(value) == arrayClass || false;
1942     };
1943
1944     /**
1945      * A fallback implementation of `Object.keys` which produces an array of the
1946      * given object's own enumerable property names.
1947      *
1948      * @private
1949      * @type Function
1950      * @param {Object} object The object to inspect.
1951      * @returns {Array} Returns an array of property names.
1952      */
1953     var shimKeys = createIterator({
1954       'args': 'object',
1955       'init': '[]',
1956       'top': 'if (!(objectTypes[typeof object])) return result',
1957       'loop': 'result.push(index)'
1958     });
1959
1960     /**
1961      * Creates an array composed of the own enumerable property names of an object.
1962      *
1963      * @static
1964      * @memberOf _
1965      * @category Objects
1966      * @param {Object} object The object to inspect.
1967      * @returns {Array} Returns an array of property names.
1968      * @example
1969      *
1970      * _.keys({ 'one': 1, 'two': 2, 'three': 3 });
1971      * // => ['one', 'two', 'three'] (property order is not guaranteed across environments)
1972      */
1973     var keys = !nativeKeys ? shimKeys : function(object) {
1974       if (!isObject(object)) {
1975         return [];
1976       }
1977       if ((support.enumPrototypes && typeof object == 'function') ||
1978           (support.nonEnumArgs && object.length && isArguments(object))) {
1979         return shimKeys(object);
1980       }
1981       return nativeKeys(object);
1982     };
1983
1984     /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */
1985     var eachIteratorOptions = {
1986       'args': 'collection, callback, thisArg',
1987       'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)",
1988       'array': "typeof length == 'number'",
1989       'keys': keys,
1990       'loop': 'if (callback(iterable[index], index, collection) === false) return result'
1991     };
1992
1993     /** Reusable iterator options for `assign` and `defaults` */
1994     var defaultsIteratorOptions = {
1995       'args': 'object, source, guard',
1996       'top':
1997         'var args = arguments,\n' +
1998         '    argsIndex = 0,\n' +
1999         "    argsLength = typeof guard == 'number' ? 2 : args.length;\n" +
2000         'while (++argsIndex < argsLength) {\n' +
2001         '  iterable = args[argsIndex];\n' +
2002         '  if (iterable && objectTypes[typeof iterable]) {',
2003       'keys': keys,
2004       'loop': "if (typeof result[index] == 'undefined') result[index] = iterable[index]",
2005       'bottom': '  }\n}'
2006     };
2007
2008     /** Reusable iterator options for `forIn` and `forOwn` */
2009     var forOwnIteratorOptions = {
2010       'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top,
2011       'array': false
2012     };
2013
2014     /**
2015      * Used to convert characters to HTML entities:
2016      *
2017      * Though the `>` character is escaped for symmetry, characters like `>` and `/`
2018      * don't require escaping in HTML and have no special meaning unless they're part
2019      * of a tag or an unquoted attribute value.
2020      * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
2021      */
2022     var htmlEscapes = {
2023       '&': '&amp;',
2024       '<': '&lt;',
2025       '>': '&gt;',
2026       '"': '&quot;',
2027       "'": '&#39;'
2028     };
2029
2030     /** Used to convert HTML entities to characters */
2031     var htmlUnescapes = invert(htmlEscapes);
2032
2033     /** Used to match HTML entities and HTML characters */
2034     var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'),
2035         reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g');
2036
2037     /**
2038      * A function compiled to iterate `arguments` objects, arrays, objects, and
2039      * strings consistenly across environments, executing the callback for each
2040      * element in the collection. The callback is bound to `thisArg` and invoked
2041      * with three arguments; (value, index|key, collection). Callbacks may exit
2042      * iteration early by explicitly returning `false`.
2043      *
2044      * @private
2045      * @type Function
2046      * @param {Array|Object|string} collection The collection to iterate over.
2047      * @param {Function} [callback=identity] The function called per iteration.
2048      * @param {*} [thisArg] The `this` binding of `callback`.
2049      * @returns {Array|Object|string} Returns `collection`.
2050      */
2051     var baseEach = createIterator(eachIteratorOptions);
2052
2053     /*--------------------------------------------------------------------------*/
2054
2055     /**
2056      * Assigns own enumerable properties of source object(s) to the destination
2057      * object. Subsequent sources will overwrite property assignments of previous
2058      * sources. If a callback is provided it will be executed to produce the
2059      * assigned values. The callback is bound to `thisArg` and invoked with two
2060      * arguments; (objectValue, sourceValue).
2061      *
2062      * @static
2063      * @memberOf _
2064      * @type Function
2065      * @alias extend
2066      * @category Objects
2067      * @param {Object} object The destination object.
2068      * @param {...Object} [source] The source objects.
2069      * @param {Function} [callback] The function to customize assigning values.
2070      * @param {*} [thisArg] The `this` binding of `callback`.
2071      * @returns {Object} Returns the destination object.
2072      * @example
2073      *
2074      * _.assign({ 'name': 'fred' }, { 'employer': 'slate' });
2075      * // => { 'name': 'fred', 'employer': 'slate' }
2076      *
2077      * var defaults = _.partialRight(_.assign, function(a, b) {
2078      *   return typeof a == 'undefined' ? b : a;
2079      * });
2080      *
2081      * var object = { 'name': 'barney' };
2082      * defaults(object, { 'name': 'fred', 'employer': 'slate' });
2083      * // => { 'name': 'barney', 'employer': 'slate' }
2084      */
2085     var assign = createIterator(defaultsIteratorOptions, {
2086       'top':
2087         defaultsIteratorOptions.top.replace(';',
2088           ';\n' +
2089           "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" +
2090           '  var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n' +
2091           "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" +
2092           '  callback = args[--argsLength];\n' +
2093           '}'
2094         ),
2095       'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]'
2096     });
2097
2098     /**
2099      * Creates a clone of `value`. If `isDeep` is `true` nested objects will also
2100      * be cloned, otherwise they will be assigned by reference. If a callback
2101      * is provided it will be executed to produce the cloned values. If the
2102      * callback returns `undefined` cloning will be handled by the method instead.
2103      * The callback is bound to `thisArg` and invoked with one argument; (value).
2104      *
2105      * @static
2106      * @memberOf _
2107      * @category Objects
2108      * @param {*} value The value to clone.
2109      * @param {boolean} [isDeep=false] Specify a deep clone.
2110      * @param {Function} [callback] The function to customize cloning values.
2111      * @param {*} [thisArg] The `this` binding of `callback`.
2112      * @returns {*} Returns the cloned value.
2113      * @example
2114      *
2115      * var characters = [
2116      *   { 'name': 'barney', 'age': 36 },
2117      *   { 'name': 'fred',   'age': 40 }
2118      * ];
2119      *
2120      * var shallow = _.clone(characters);
2121      * shallow[0] === characters[0];
2122      * // => true
2123      *
2124      * var deep = _.clone(characters, true);
2125      * deep[0] === characters[0];
2126      * // => false
2127      *
2128      * _.mixin({
2129      *   'clone': _.partialRight(_.clone, function(value) {
2130      *     return _.isElement(value) ? value.cloneNode(false) : undefined;
2131      *   })
2132      * });
2133      *
2134      * var clone = _.clone(document.body);
2135      * clone.childNodes.length;
2136      * // => 0
2137      */
2138     function clone(value, isDeep, callback, thisArg) {
2139       // allows working with "Collections" methods without using their `index`
2140       // and `collection` arguments for `isDeep` and `callback`
2141       if (typeof isDeep != 'boolean' && isDeep != null) {
2142         thisArg = callback;
2143         callback = isDeep;
2144         isDeep = false;
2145       }
2146       return baseClone(value, isDeep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1));
2147     }
2148
2149     /**
2150      * Creates a deep clone of `value`. If a callback is provided it will be
2151      * executed to produce the cloned values. If the callback returns `undefined`
2152      * cloning will be handled by the method instead. The callback is bound to
2153      * `thisArg` and invoked with one argument; (value).
2154      *
2155      * Note: This method is loosely based on the structured clone algorithm. Functions
2156      * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and
2157      * objects created by constructors other than `Object` are cloned to plain `Object` objects.
2158      * See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm.
2159      *
2160      * @static
2161      * @memberOf _
2162      * @category Objects
2163      * @param {*} value The value to deep clone.
2164      * @param {Function} [callback] The function to customize cloning values.
2165      * @param {*} [thisArg] The `this` binding of `callback`.
2166      * @returns {*} Returns the deep cloned value.
2167      * @example
2168      *
2169      * var characters = [
2170      *   { 'name': 'barney', 'age': 36 },
2171      *   { 'name': 'fred',   'age': 40 }
2172      * ];
2173      *
2174      * var deep = _.cloneDeep(characters);
2175      * deep[0] === characters[0];
2176      * // => false
2177      *
2178      * var view = {
2179      *   'label': 'docs',
2180      *   'node': element
2181      * };
2182      *
2183      * var clone = _.cloneDeep(view, function(value) {
2184      *   return _.isElement(value) ? value.cloneNode(true) : undefined;
2185      * });
2186      *
2187      * clone.node == view.node;
2188      * // => false
2189      */
2190     function cloneDeep(value, callback, thisArg) {
2191       return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1));
2192     }
2193
2194     /**
2195      * Creates an object that inherits from the given `prototype` object. If a
2196      * `properties` object is provided its own enumerable properties are assigned
2197      * to the created object.
2198      *
2199      * @static
2200      * @memberOf _
2201      * @category Objects
2202      * @param {Object} prototype The object to inherit from.
2203      * @param {Object} [properties] The properties to assign to the object.
2204      * @returns {Object} Returns the new object.
2205      * @example
2206      *
2207      * function Shape() {
2208      *   this.x = 0;
2209      *   this.y = 0;
2210      * }
2211      *
2212      * function Circle() {
2213      *   Shape.call(this);
2214      * }
2215      *
2216      * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle });
2217      *
2218      * var circle = new Circle;
2219      * circle instanceof Circle;
2220      * // => true
2221      *
2222      * circle instanceof Shape;
2223      * // => true
2224      */
2225     function create(prototype, properties) {
2226       var result = baseCreate(prototype);
2227       return properties ? assign(result, properties) : result;
2228     }
2229
2230     /**
2231      * Assigns own enumerable properties of source object(s) to the destination
2232      * object for all destination properties that resolve to `undefined`. Once a
2233      * property is set, additional defaults of the same property will be ignored.
2234      *
2235      * @static
2236      * @memberOf _
2237      * @type Function
2238      * @category Objects
2239      * @param {Object} object The destination object.
2240      * @param {...Object} [source] The source objects.
2241      * @param- {Object} [guard] Allows working with `_.reduce` without using its
2242      *  `key` and `object` arguments as sources.
2243      * @returns {Object} Returns the destination object.
2244      * @example
2245      *
2246      * var object = { 'name': 'barney' };
2247      * _.defaults(object, { 'name': 'fred', 'employer': 'slate' });
2248      * // => { 'name': 'barney', 'employer': 'slate' }
2249      */
2250     var defaults = createIterator(defaultsIteratorOptions);
2251
2252     /**
2253      * This method is like `_.findIndex` except that it returns the key of the
2254      * first element that passes the callback check, instead of the element itself.
2255      *
2256      * If a property name is provided for `callback` the created "_.pluck" style
2257      * callback will return the property value of the given element.
2258      *
2259      * If an object is provided for `callback` the created "_.where" style callback
2260      * will return `true` for elements that have the properties of the given object,
2261      * else `false`.
2262      *
2263      * @static
2264      * @memberOf _
2265      * @category Objects
2266      * @param {Object} object The object to search.
2267      * @param {Function|Object|string} [callback=identity] The function called per
2268      *  iteration. If a property name or object is provided it will be used to
2269      *  create a "_.pluck" or "_.where" style callback, respectively.
2270      * @param {*} [thisArg] The `this` binding of `callback`.
2271      * @returns {string|undefined} Returns the key of the found element, else `undefined`.
2272      * @example
2273      *
2274      * var characters = {
2275      *   'barney': {  'age': 36, 'blocked': false },
2276      *   'fred': {    'age': 40, 'blocked': true },
2277      *   'pebbles': { 'age': 1,  'blocked': false }
2278      * };
2279      *
2280      * _.findKey(characters, function(chr) {
2281      *   return chr.age < 40;
2282      * });
2283      * // => 'barney' (property order is not guaranteed across environments)
2284      *
2285      * // using "_.where" callback shorthand
2286      * _.findKey(characters, { 'age': 1 });
2287      * // => 'pebbles'
2288      *
2289      * // using "_.pluck" callback shorthand
2290      * _.findKey(characters, 'blocked');
2291      * // => 'fred'
2292      */
2293     function findKey(object, callback, thisArg) {
2294       var result;
2295       callback = lodash.createCallback(callback, thisArg, 3);
2296       forOwn(object, function(value, key, object) {
2297         if (callback(value, key, object)) {
2298           result = key;
2299           return false;
2300         }
2301       });
2302       return result;
2303     }
2304
2305     /**
2306      * This method is like `_.findKey` except that it iterates over elements
2307      * of a `collection` in the opposite order.
2308      *
2309      * If a property name is provided for `callback` the created "_.pluck" style
2310      * callback will return the property value of the given element.
2311      *
2312      * If an object is provided for `callback` the created "_.where" style callback
2313      * will return `true` for elements that have the properties of the given object,
2314      * else `false`.
2315      *
2316      * @static
2317      * @memberOf _
2318      * @category Objects
2319      * @param {Object} object The object to search.
2320      * @param {Function|Object|string} [callback=identity] The function called per
2321      *  iteration. If a property name or object is provided it will be used to
2322      *  create a "_.pluck" or "_.where" style callback, respectively.
2323      * @param {*} [thisArg] The `this` binding of `callback`.
2324      * @returns {string|undefined} Returns the key of the found element, else `undefined`.
2325      * @example
2326      *
2327      * var characters = {
2328      *   'barney': {  'age': 36, 'blocked': true },
2329      *   'fred': {    'age': 40, 'blocked': false },
2330      *   'pebbles': { 'age': 1,  'blocked': true }
2331      * };
2332      *
2333      * _.findLastKey(characters, function(chr) {
2334      *   return chr.age < 40;
2335      * });
2336      * // => returns `pebbles`, assuming `_.findKey` returns `barney`
2337      *
2338      * // using "_.where" callback shorthand
2339      * _.findLastKey(characters, { 'age': 40 });
2340      * // => 'fred'
2341      *
2342      * // using "_.pluck" callback shorthand
2343      * _.findLastKey(characters, 'blocked');
2344      * // => 'pebbles'
2345      */
2346     function findLastKey(object, callback, thisArg) {
2347       var result;
2348       callback = lodash.createCallback(callback, thisArg, 3);
2349       forOwnRight(object, function(value, key, object) {
2350         if (callback(value, key, object)) {
2351           result = key;
2352           return false;
2353         }
2354       });
2355       return result;
2356     }
2357
2358     /**
2359      * Iterates over own and inherited enumerable properties of an object,
2360      * executing the callback for each property. The callback is bound to `thisArg`
2361      * and invoked with three arguments; (value, key, object). Callbacks may exit
2362      * iteration early by explicitly returning `false`.
2363      *
2364      * @static
2365      * @memberOf _
2366      * @type Function
2367      * @category Objects
2368      * @param {Object} object The object to iterate over.
2369      * @param {Function} [callback=identity] The function called per iteration.
2370      * @param {*} [thisArg] The `this` binding of `callback`.
2371      * @returns {Object} Returns `object`.
2372      * @example
2373      *
2374      * function Shape() {
2375      *   this.x = 0;
2376      *   this.y = 0;
2377      * }
2378      *
2379      * Shape.prototype.move = function(x, y) {
2380      *   this.x += x;
2381      *   this.y += y;
2382      * };
2383      *
2384      * _.forIn(new Shape, function(value, key) {
2385      *   console.log(key);
2386      * });
2387      * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments)
2388      */
2389     var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, {
2390       'useHas': false
2391     });
2392
2393     /**
2394      * This method is like `_.forIn` except that it iterates over elements
2395      * of a `collection` in the opposite order.
2396      *
2397      * @static
2398      * @memberOf _
2399      * @category Objects
2400      * @param {Object} object The object to iterate over.
2401      * @param {Function} [callback=identity] The function called per iteration.
2402      * @param {*} [thisArg] The `this` binding of `callback`.
2403      * @returns {Object} Returns `object`.
2404      * @example
2405      *
2406      * function Shape() {
2407      *   this.x = 0;
2408      *   this.y = 0;
2409      * }
2410      *
2411      * Shape.prototype.move = function(x, y) {
2412      *   this.x += x;
2413      *   this.y += y;
2414      * };
2415      *
2416      * _.forInRight(new Shape, function(value, key) {
2417      *   console.log(key);
2418      * });
2419      * // => logs 'move', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'move'
2420      */
2421     function forInRight(object, callback, thisArg) {
2422       var pairs = [];
2423
2424       forIn(object, function(value, key) {
2425         pairs.push(key, value);
2426       });
2427
2428       var length = pairs.length;
2429       callback = baseCreateCallback(callback, thisArg, 3);
2430       while (length--) {
2431         if (callback(pairs[length--], pairs[length], object) === false) {
2432           break;
2433         }
2434       }
2435       return object;
2436     }
2437
2438     /**
2439      * Iterates over own enumerable properties of an object, executing the callback
2440      * for each property. The callback is bound to `thisArg` and invoked with three
2441      * arguments; (value, key, object). Callbacks may exit iteration early by
2442      * explicitly returning `false`.
2443      *
2444      * @static
2445      * @memberOf _
2446      * @type Function
2447      * @category Objects
2448      * @param {Object} object The object to iterate over.
2449      * @param {Function} [callback=identity] The function called per iteration.
2450      * @param {*} [thisArg] The `this` binding of `callback`.
2451      * @returns {Object} Returns `object`.
2452      * @example
2453      *
2454      * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
2455      *   console.log(key);
2456      * });
2457      * // => logs '0', '1', and 'length' (property order is not guaranteed across environments)
2458      */
2459     var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions);
2460
2461     /**
2462      * This method is like `_.forOwn` except that it iterates over elements
2463      * of a `collection` in the opposite order.
2464      *
2465      * @static
2466      * @memberOf _
2467      * @category Objects
2468      * @param {Object} object The object to iterate over.
2469      * @param {Function} [callback=identity] The function called per iteration.
2470      * @param {*} [thisArg] The `this` binding of `callback`.
2471      * @returns {Object} Returns `object`.
2472      * @example
2473      *
2474      * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
2475      *   console.log(key);
2476      * });
2477      * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length'
2478      */
2479     function forOwnRight(object, callback, thisArg) {
2480       var props = keys(object),
2481           length = props.length;
2482
2483       callback = baseCreateCallback(callback, thisArg, 3);
2484       while (length--) {
2485         var key = props[length];
2486         if (callback(object[key], key, object) === false) {
2487           break;
2488         }
2489       }
2490       return object;
2491     }
2492
2493     /**
2494      * Creates a sorted array of property names of all enumerable properties,
2495      * own and inherited, of `object` that have function values.
2496      *
2497      * @static
2498      * @memberOf _
2499      * @alias methods
2500      * @category Objects
2501      * @param {Object} object The object to inspect.
2502      * @returns {Array} Returns an array of property names that have function values.
2503      * @example
2504      *
2505      * _.functions(_);
2506      * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
2507      */
2508     function functions(object) {
2509       var result = [];
2510       forIn(object, function(value, key) {
2511         if (isFunction(value)) {
2512           result.push(key);
2513         }
2514       });
2515       return result.sort();
2516     }
2517
2518     /**
2519      * Checks if the specified property name exists as a direct property of `object`,
2520      * instead of an inherited property.
2521      *
2522      * @static
2523      * @memberOf _
2524      * @category Objects
2525      * @param {Object} object The object to inspect.
2526      * @param {string} key The name of the property to check.
2527      * @returns {boolean} Returns `true` if key is a direct property, else `false`.
2528      * @example
2529      *
2530      * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
2531      * // => true
2532      */
2533     function has(object, key) {
2534       return object ? hasOwnProperty.call(object, key) : false;
2535     }
2536
2537     /**
2538      * Creates an object composed of the inverted keys and values of the given object.
2539      *
2540      * @static
2541      * @memberOf _
2542      * @category Objects
2543      * @param {Object} object The object to invert.
2544      * @returns {Object} Returns the created inverted object.
2545      * @example
2546      *
2547      * _.invert({ 'first': 'fred', 'second': 'barney' });
2548      * // => { 'fred': 'first', 'barney': 'second' }
2549      */
2550     function invert(object) {
2551       var index = -1,
2552           props = keys(object),
2553           length = props.length,
2554           result = {};
2555
2556       while (++index < length) {
2557         var key = props[index];
2558         result[object[key]] = key;
2559       }
2560       return result;
2561     }
2562
2563     /**
2564      * Checks if `value` is a boolean value.
2565      *
2566      * @static
2567      * @memberOf _
2568      * @category Objects
2569      * @param {*} value The value to check.
2570      * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`.
2571      * @example
2572      *
2573      * _.isBoolean(null);
2574      * // => false
2575      */
2576     function isBoolean(value) {
2577       return value === true || value === false ||
2578         value && typeof value == 'object' && toString.call(value) == boolClass || false;
2579     }
2580
2581     /**
2582      * Checks if `value` is a date.
2583      *
2584      * @static
2585      * @memberOf _
2586      * @category Objects
2587      * @param {*} value The value to check.
2588      * @returns {boolean} Returns `true` if the `value` is a date, else `false`.
2589      * @example
2590      *
2591      * _.isDate(new Date);
2592      * // => true
2593      */
2594     function isDate(value) {
2595       return value && typeof value == 'object' && toString.call(value) == dateClass || false;
2596     }
2597
2598     /**
2599      * Checks if `value` is a DOM element.
2600      *
2601      * @static
2602      * @memberOf _
2603      * @category Objects
2604      * @param {*} value The value to check.
2605      * @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`.
2606      * @example
2607      *
2608      * _.isElement(document.body);
2609      * // => true
2610      */
2611     function isElement(value) {
2612       return value && value.nodeType === 1 || false;
2613     }
2614
2615     /**
2616      * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a
2617      * length of `0` and objects with no own enumerable properties are considered
2618      * "empty".
2619      *
2620      * @static
2621      * @memberOf _
2622      * @category Objects
2623      * @param {Array|Object|string} value The value to inspect.
2624      * @returns {boolean} Returns `true` if the `value` is empty, else `false`.
2625      * @example
2626      *
2627      * _.isEmpty([1, 2, 3]);
2628      * // => false
2629      *
2630      * _.isEmpty({});
2631      * // => true
2632      *
2633      * _.isEmpty('');
2634      * // => true
2635      */
2636     function isEmpty(value) {
2637       var result = true;
2638       if (!value) {
2639         return result;
2640       }
2641       var className = toString.call(value),
2642           length = value.length;
2643
2644       if ((className == arrayClass || className == stringClass ||
2645           (support.argsClass ? className == argsClass : isArguments(value))) ||
2646           (className == objectClass && typeof length == 'number' && isFunction(value.splice))) {
2647         return !length;
2648       }
2649       forOwn(value, function() {
2650         return (result = false);
2651       });
2652       return result;
2653     }
2654
2655     /**
2656      * Performs a deep comparison between two values to determine if they are
2657      * equivalent to each other. If a callback is provided it will be executed
2658      * to compare values. If the callback returns `undefined` comparisons will
2659      * be handled by the method instead. The callback is bound to `thisArg` and
2660      * invoked with two arguments; (a, b).
2661      *
2662      * @static
2663      * @memberOf _
2664      * @category Objects
2665      * @param {*} a The value to compare.
2666      * @param {*} b The other value to compare.
2667      * @param {Function} [callback] The function to customize comparing values.
2668      * @param {*} [thisArg] The `this` binding of `callback`.
2669      * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2670      * @example
2671      *
2672      * var object = { 'name': 'fred' };
2673      * var copy = { 'name': 'fred' };
2674      *
2675      * object == copy;
2676      * // => false
2677      *
2678      * _.isEqual(object, copy);
2679      * // => true
2680      *
2681      * var words = ['hello', 'goodbye'];
2682      * var otherWords = ['hi', 'goodbye'];
2683      *
2684      * _.isEqual(words, otherWords, function(a, b) {
2685      *   var reGreet = /^(?:hello|hi)$/i,
2686      *       aGreet = _.isString(a) && reGreet.test(a),
2687      *       bGreet = _.isString(b) && reGreet.test(b);
2688      *
2689      *   return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
2690      * });
2691      * // => true
2692      */
2693     function isEqual(a, b, callback, thisArg) {
2694       return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2));
2695     }
2696
2697     /**
2698      * Checks if `value` is, or can be coerced to, a finite number.
2699      *
2700      * Note: This is not the same as native `isFinite` which will return true for
2701      * booleans and empty strings. See http://es5.github.io/#x15.1.2.5.
2702      *
2703      * @static
2704      * @memberOf _
2705      * @category Objects
2706      * @param {*} value The value to check.
2707      * @returns {boolean} Returns `true` if the `value` is finite, else `false`.
2708      * @example
2709      *
2710      * _.isFinite(-101);
2711      * // => true
2712      *
2713      * _.isFinite('10');
2714      * // => true
2715      *
2716      * _.isFinite(true);
2717      * // => false
2718      *
2719      * _.isFinite('');
2720      * // => false
2721      *
2722      * _.isFinite(Infinity);
2723      * // => false
2724      */
2725     function isFinite(value) {
2726       return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));
2727     }
2728
2729     /**
2730      * Checks if `value` is a function.
2731      *
2732      * @static
2733      * @memberOf _
2734      * @category Objects
2735      * @param {*} value The value to check.
2736      * @returns {boolean} Returns `true` if the `value` is a function, else `false`.
2737      * @example
2738      *
2739      * _.isFunction(_);
2740      * // => true
2741      */
2742     function isFunction(value) {
2743       return typeof value == 'function';
2744     }
2745     // fallback for older versions of Chrome and Safari
2746     if (isFunction(/x/)) {
2747       isFunction = function(value) {
2748         return typeof value == 'function' && toString.call(value) == funcClass;
2749       };
2750     }
2751
2752     /**
2753      * Checks if `value` is the language type of Object.
2754      * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2755      *
2756      * @static
2757      * @memberOf _
2758      * @category Objects
2759      * @param {*} value The value to check.
2760      * @returns {boolean} Returns `true` if the `value` is an object, else `false`.
2761      * @example
2762      *
2763      * _.isObject({});
2764      * // => true
2765      *
2766      * _.isObject([1, 2, 3]);
2767      * // => true
2768      *
2769      * _.isObject(1);
2770      * // => false
2771      */
2772     function isObject(value) {
2773       // check if the value is the ECMAScript language type of Object
2774       // http://es5.github.io/#x8
2775       // and avoid a V8 bug
2776       // http://code.google.com/p/v8/issues/detail?id=2291
2777       return !!(value && objectTypes[typeof value]);
2778     }
2779
2780     /**
2781      * Checks if `value` is `NaN`.
2782      *
2783      * Note: This is not the same as native `isNaN` which will return `true` for
2784      * `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4.
2785      *
2786      * @static
2787      * @memberOf _
2788      * @category Objects
2789      * @param {*} value The value to check.
2790      * @returns {boolean} Returns `true` if the `value` is `NaN`, else `false`.
2791      * @example
2792      *
2793      * _.isNaN(NaN);
2794      * // => true
2795      *
2796      * _.isNaN(new Number(NaN));
2797      * // => true
2798      *
2799      * isNaN(undefined);
2800      * // => true
2801      *
2802      * _.isNaN(undefined);
2803      * // => false
2804      */
2805     function isNaN(value) {
2806       // `NaN` as a primitive is the only value that is not equal to itself
2807       // (perform the [[Class]] check first to avoid errors with some host objects in IE)
2808       return isNumber(value) && value != +value;
2809     }
2810
2811     /**
2812      * Checks if `value` is `null`.
2813      *
2814      * @static
2815      * @memberOf _
2816      * @category Objects
2817      * @param {*} value The value to check.
2818      * @returns {boolean} Returns `true` if the `value` is `null`, else `false`.
2819      * @example
2820      *
2821      * _.isNull(null);
2822      * // => true
2823      *
2824      * _.isNull(undefined);
2825      * // => false
2826      */
2827     function isNull(value) {
2828       return value === null;
2829     }
2830
2831     /**
2832      * Checks if `value` is a number.
2833      *
2834      * Note: `NaN` is considered a number. See http://es5.github.io/#x8.5.
2835      *
2836      * @static
2837      * @memberOf _
2838      * @category Objects
2839      * @param {*} value The value to check.
2840      * @returns {boolean} Returns `true` if the `value` is a number, else `false`.
2841      * @example
2842      *
2843      * _.isNumber(8.4 * 5);
2844      * // => true
2845      */
2846     function isNumber(value) {
2847       return typeof value == 'number' ||
2848         value && typeof value == 'object' && toString.call(value) == numberClass || false;
2849     }
2850
2851     /**
2852      * Checks if `value` is an object created by the `Object` constructor.
2853      *
2854      * @static
2855      * @memberOf _
2856      * @category Objects
2857      * @param {*} value The value to check.
2858      * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2859      * @example
2860      *
2861      * function Shape() {
2862      *   this.x = 0;
2863      *   this.y = 0;
2864      * }
2865      *
2866      * _.isPlainObject(new Shape);
2867      * // => false
2868      *
2869      * _.isPlainObject([1, 2, 3]);
2870      * // => false
2871      *
2872      * _.isPlainObject({ 'x': 0, 'y': 0 });
2873      * // => true
2874      */
2875     var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
2876       if (!(value && toString.call(value) == objectClass) || (!support.argsClass && isArguments(value))) {
2877         return false;
2878       }
2879       var valueOf = value.valueOf,
2880           objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
2881
2882       return objProto
2883         ? (value == objProto || getPrototypeOf(value) == objProto)
2884         : shimIsPlainObject(value);
2885     };
2886
2887     /**
2888      * Checks if `value` is a regular expression.
2889      *
2890      * @static
2891      * @memberOf _
2892      * @category Objects
2893      * @param {*} value The value to check.
2894      * @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`.
2895      * @example
2896      *
2897      * _.isRegExp(/fred/);
2898      * // => true
2899      */
2900     function isRegExp(value) {
2901       return value && objectTypes[typeof value] && toString.call(value) == regexpClass || false;
2902     }
2903
2904     /**
2905      * Checks if `value` is a string.
2906      *
2907      * @static
2908      * @memberOf _
2909      * @category Objects
2910      * @param {*} value The value to check.
2911      * @returns {boolean} Returns `true` if the `value` is a string, else `false`.
2912      * @example
2913      *
2914      * _.isString('fred');
2915      * // => true
2916      */
2917     function isString(value) {
2918       return typeof value == 'string' ||
2919         value && typeof value == 'object' && toString.call(value) == stringClass || false;
2920     }
2921
2922     /**
2923      * Checks if `value` is `undefined`.
2924      *
2925      * @static
2926      * @memberOf _
2927      * @category Objects
2928      * @param {*} value The value to check.
2929      * @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`.
2930      * @example
2931      *
2932      * _.isUndefined(void 0);
2933      * // => true
2934      */
2935     function isUndefined(value) {
2936       return typeof value == 'undefined';
2937     }
2938
2939     /**
2940      * Creates an object with the same keys as `object` and values generated by
2941      * running each own enumerable property of `object` through the callback.
2942      * The callback is bound to `thisArg` and invoked with three arguments;
2943      * (value, key, object).
2944      *
2945      * If a property name is provided for `callback` the created "_.pluck" style
2946      * callback will return the property value of the given element.
2947      *
2948      * If an object is provided for `callback` the created "_.where" style callback
2949      * will return `true` for elements that have the properties of the given object,
2950      * else `false`.
2951      *
2952      * @static
2953      * @memberOf _
2954      * @category Objects
2955      * @param {Object} object The object to iterate over.
2956      * @param {Function|Object|string} [callback=identity] The function called
2957      *  per iteration. If a property name or object is provided it will be used
2958      *  to create a "_.pluck" or "_.where" style callback, respectively.
2959      * @param {*} [thisArg] The `this` binding of `callback`.
2960      * @returns {Array} Returns a new object with values of the results of each `callback` execution.
2961      * @example
2962      *
2963      * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
2964      * // => { 'a': 3, 'b': 6, 'c': 9 }
2965      *
2966      * var characters = {
2967      *   'fred': { 'name': 'fred', 'age': 40 },
2968      *   'pebbles': { 'name': 'pebbles', 'age': 1 }
2969      * };
2970      *
2971      * // using "_.pluck" callback shorthand
2972      * _.mapValues(characters, 'age');
2973      * // => { 'fred': 40, 'pebbles': 1 }
2974      */
2975     function mapValues(object, callback, thisArg) {
2976       var result = {};
2977       callback = lodash.createCallback(callback, thisArg, 3);
2978
2979       forOwn(object, function(value, key, object) {
2980         result[key] = callback(value, key, object);
2981       });
2982       return result;
2983     }
2984
2985     /**
2986      * Recursively merges own enumerable properties of the source object(s), that
2987      * don't resolve to `undefined` into the destination object. Subsequent sources
2988      * will overwrite property assignments of previous sources. If a callback is
2989      * provided it will be executed to produce the merged values of the destination
2990      * and source properties. If the callback returns `undefined` merging will
2991      * be handled by the method instead. The callback is bound to `thisArg` and
2992      * invoked with two arguments; (objectValue, sourceValue).
2993      *
2994      * @static
2995      * @memberOf _
2996      * @category Objects
2997      * @param {Object} object The destination object.
2998      * @param {...Object} [source] The source objects.
2999      * @param {Function} [callback] The function to customize merging properties.
3000      * @param {*} [thisArg] The `this` binding of `callback`.
3001      * @returns {Object} Returns the destination object.
3002      * @example
3003      *
3004      * var names = {
3005      *   'characters': [
3006      *     { 'name': 'barney' },
3007      *     { 'name': 'fred' }
3008      *   ]
3009      * };
3010      *
3011      * var ages = {
3012      *   'characters': [
3013      *     { 'age': 36 },
3014      *     { 'age': 40 }
3015      *   ]
3016      * };
3017      *
3018      * _.merge(names, ages);
3019      * // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] }
3020      *
3021      * var food = {
3022      *   'fruits': ['apple'],
3023      *   'vegetables': ['beet']
3024      * };
3025      *
3026      * var otherFood = {
3027      *   'fruits': ['banana'],
3028      *   'vegetables': ['carrot']
3029      * };
3030      *
3031      * _.merge(food, otherFood, function(a, b) {
3032      *   return _.isArray(a) ? a.concat(b) : undefined;
3033      * });
3034      * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }
3035      */
3036     function merge(object) {
3037       var args = arguments,
3038           length = 2;
3039
3040       if (!isObject(object)) {
3041         return object;
3042       }
3043       // allows working with `_.reduce` and `_.reduceRight` without using
3044       // their `index` and `collection` arguments
3045       if (typeof args[2] != 'number') {
3046         length = args.length;
3047       }
3048       if (length > 3 && typeof args[length - 2] == 'function') {
3049         var callback = baseCreateCallback(args[--length - 1], args[length--], 2);
3050       } else if (length > 2 && typeof args[length - 1] == 'function') {
3051         callback = args[--length];
3052       }
3053       var sources = slice(arguments, 1, length),
3054           index = -1,
3055           stackA = getArray(),
3056           stackB = getArray();
3057
3058       while (++index < length) {
3059         baseMerge(object, sources[index], callback, stackA, stackB);
3060       }
3061       releaseArray(stackA);
3062       releaseArray(stackB);
3063       return object;
3064     }
3065
3066     /**
3067      * Creates a shallow clone of `object` excluding the specified properties.
3068      * Property names may be specified as individual arguments or as arrays of
3069      * property names. If a callback is provided it will be executed for each
3070      * property of `object` omitting the properties the callback returns truey
3071      * for. The callback is bound to `thisArg` and invoked with three arguments;
3072      * (value, key, object).
3073      *
3074      * @static
3075      * @memberOf _
3076      * @category Objects
3077      * @param {Object} object The source object.
3078      * @param {Function|...string|string[]} [callback] The properties to omit or the
3079      *  function called per iteration.
3080      * @param {*} [thisArg] The `this` binding of `callback`.
3081      * @returns {Object} Returns an object without the omitted properties.
3082      * @example
3083      *
3084      * _.omit({ 'name': 'fred', 'age': 40 }, 'age');
3085      * // => { 'name': 'fred' }
3086      *
3087      * _.omit({ 'name': 'fred', 'age': 40 }, function(value) {
3088      *   return typeof value == 'number';
3089      * });
3090      * // => { 'name': 'fred' }
3091      */
3092     function omit(object, callback, thisArg) {
3093       var result = {};
3094       if (typeof callback != 'function') {
3095         var props = [];
3096         forIn(object, function(value, key) {
3097           props.push(key);
3098         });
3099         props = baseDifference(props, baseFlatten(arguments, true, false, 1));
3100
3101         var index = -1,
3102             length = props.length;
3103
3104         while (++index < length) {
3105           var key = props[index];
3106           result[key] = object[key];
3107         }
3108       } else {
3109         callback = lodash.createCallback(callback, thisArg, 3);
3110         forIn(object, function(value, key, object) {
3111           if (!callback(value, key, object)) {
3112             result[key] = value;
3113           }
3114         });
3115       }
3116       return result;
3117     }
3118
3119     /**
3120      * Creates a two dimensional array of an object's key-value pairs,
3121      * i.e. `[[key1, value1], [key2, value2]]`.
3122      *
3123      * @static
3124      * @memberOf _
3125      * @category Objects
3126      * @param {Object} object The object to inspect.
3127      * @returns {Array} Returns new array of key-value pairs.
3128      * @example
3129      *
3130      * _.pairs({ 'barney': 36, 'fred': 40 });
3131      * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments)
3132      */
3133     function pairs(object) {
3134       var index = -1,
3135           props = keys(object),
3136           length = props.length,
3137           result = Array(length);
3138
3139       while (++index < length) {
3140         var key = props[index];
3141         result[index] = [key, object[key]];
3142       }
3143       return result;
3144     }
3145
3146     /**
3147      * Creates a shallow clone of `object` composed of the specified properties.
3148      * Property names may be specified as individual arguments or as arrays of
3149      * property names. If a callback is provided it will be executed for each
3150      * property of `object` picking the properties the callback returns truey
3151      * for. The callback is bound to `thisArg` and invoked with three arguments;
3152      * (value, key, object).
3153      *
3154      * @static
3155      * @memberOf _
3156      * @category Objects
3157      * @param {Object} object The source object.
3158      * @param {Function|...string|string[]} [callback] The function called per
3159      *  iteration or property names to pick, specified as individual property
3160      *  names or arrays of property names.
3161      * @param {*} [thisArg] The `this` binding of `callback`.
3162      * @returns {Object} Returns an object composed of the picked properties.
3163      * @example
3164      *
3165      * _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name');
3166      * // => { 'name': 'fred' }
3167      *
3168      * _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) {
3169      *   return key.charAt(0) != '_';
3170      * });
3171      * // => { 'name': 'fred' }
3172      */
3173     function pick(object, callback, thisArg) {
3174       var result = {};
3175       if (typeof callback != 'function') {
3176         var index = -1,
3177             props = baseFlatten(arguments, true, false, 1),
3178             length = isObject(object) ? props.length : 0;
3179
3180         while (++index < length) {
3181           var key = props[index];
3182           if (key in object) {
3183             result[key] = object[key];
3184           }
3185         }
3186       } else {
3187         callback = lodash.createCallback(callback, thisArg, 3);
3188         forIn(object, function(value, key, object) {
3189           if (callback(value, key, object)) {
3190             result[key] = value;
3191           }
3192         });
3193       }
3194       return result;
3195     }
3196
3197     /**
3198      * An alternative to `_.reduce` this method transforms `object` to a new
3199      * `accumulator` object which is the result of running each of its own
3200      * enumerable properties through a callback, with each callback execution
3201      * potentially mutating the `accumulator` object. The callback is bound to
3202      * `thisArg` and invoked with four arguments; (accumulator, value, key, object).
3203      * Callbacks may exit iteration early by explicitly returning `false`.
3204      *
3205      * @static
3206      * @memberOf _
3207      * @category Objects
3208      * @param {Array|Object} object The object to iterate over.
3209      * @param {Function} [callback=identity] The function called per iteration.
3210      * @param {*} [accumulator] The custom accumulator value.
3211      * @param {*} [thisArg] The `this` binding of `callback`.
3212      * @returns {*} Returns the accumulated value.
3213      * @example
3214      *
3215      * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) {
3216      *   num *= num;
3217      *   if (num % 2) {
3218      *     return result.push(num) < 3;
3219      *   }
3220      * });
3221      * // => [1, 9, 25]
3222      *
3223      * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
3224      *   result[key] = num * 3;
3225      * });
3226      * // => { 'a': 3, 'b': 6, 'c': 9 }
3227      */
3228     function transform(object, callback, accumulator, thisArg) {
3229       var isArr = isArray(object);
3230       if (accumulator == null) {
3231         if (isArr) {
3232           accumulator = [];
3233         } else {
3234           var ctor = object && object.constructor,
3235               proto = ctor && ctor.prototype;
3236
3237           accumulator = baseCreate(proto);
3238         }
3239       }
3240       if (callback) {
3241         callback = lodash.createCallback(callback, thisArg, 4);
3242         (isArr ? baseEach : forOwn)(object, function(value, index, object) {
3243           return callback(accumulator, value, index, object);
3244         });
3245       }
3246       return accumulator;
3247     }
3248
3249     /**
3250      * Creates an array composed of the own enumerable property values of `object`.
3251      *
3252      * @static
3253      * @memberOf _
3254      * @category Objects
3255      * @param {Object} object The object to inspect.
3256      * @returns {Array} Returns an array of property values.
3257      * @example
3258      *
3259      * _.values({ 'one': 1, 'two': 2, 'three': 3 });
3260      * // => [1, 2, 3] (property order is not guaranteed across environments)
3261      */
3262     function values(object) {
3263       var index = -1,
3264           props = keys(object),
3265           length = props.length,
3266           result = Array(length);
3267
3268       while (++index < length) {
3269         result[index] = object[props[index]];
3270       }
3271       return result;
3272     }
3273
3274     /*--------------------------------------------------------------------------*/
3275
3276     /**
3277      * Creates an array of elements from the specified indexes, or keys, of the
3278      * `collection`. Indexes may be specified as individual arguments or as arrays
3279      * of indexes.
3280      *
3281      * @static
3282      * @memberOf _
3283      * @category Collections
3284      * @param {Array|Object|string} collection The collection to iterate over.
3285      * @param {...(number|number[]|string|string[])} [index] The indexes of `collection`
3286      *   to retrieve, specified as individual indexes or arrays of indexes.
3287      * @returns {Array} Returns a new array of elements corresponding to the
3288      *  provided indexes.
3289      * @example
3290      *
3291      * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
3292      * // => ['a', 'c', 'e']
3293      *
3294      * _.at(['fred', 'barney', 'pebbles'], 0, 2);
3295      * // => ['fred', 'pebbles']
3296      */
3297     function at(collection) {
3298       var args = arguments,
3299           index = -1,
3300           props = baseFlatten(args, true, false, 1),
3301           length = (args[2] && args[2][args[1]] === collection) ? 1 : props.length,
3302           result = Array(length);
3303
3304       if (support.unindexedChars && isString(collection)) {
3305         collection = collection.split('');
3306       }
3307       while(++index < length) {
3308         result[index] = collection[props[index]];
3309       }
3310       return result;
3311     }
3312
3313     /**
3314      * Checks if a given value is present in a collection using strict equality
3315      * for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the
3316      * offset from the end of the collection.
3317      *
3318      * @static
3319      * @memberOf _
3320      * @alias include
3321      * @category Collections
3322      * @param {Array|Object|string} collection The collection to iterate over.
3323      * @param {*} target The value to check for.
3324      * @param {number} [fromIndex=0] The index to search from.
3325      * @returns {boolean} Returns `true` if the `target` element is found, else `false`.
3326      * @example
3327      *
3328      * _.contains([1, 2, 3], 1);
3329      * // => true
3330      *
3331      * _.contains([1, 2, 3], 1, 2);
3332      * // => false
3333      *
3334      * _.contains({ 'name': 'fred', 'age': 40 }, 'fred');
3335      * // => true
3336      *
3337      * _.contains('pebbles', 'eb');
3338      * // => true
3339      */
3340     function contains(collection, target, fromIndex) {
3341       var index = -1,
3342           indexOf = getIndexOf(),
3343           length = collection ? collection.length : 0,
3344           result = false;
3345
3346       fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0;
3347       if (isArray(collection)) {
3348         result = indexOf(collection, target, fromIndex) > -1;
3349       } else if (typeof length == 'number') {
3350         result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1;
3351       } else {
3352         baseEach(collection, function(value) {
3353           if (++index >= fromIndex) {
3354             return !(result = value === target);
3355           }
3356         });
3357       }
3358       return result;
3359     }
3360
3361     /**
3362      * Creates an object composed of keys generated from the results of running
3363      * each element of `collection` through the callback. The corresponding value
3364      * of each key is the number of times the key was returned by the callback.
3365      * The callback is bound to `thisArg` and invoked with three arguments;
3366      * (value, index|key, collection).
3367      *
3368      * If a property name is provided for `callback` the created "_.pluck" style
3369      * callback will return the property value of the given element.
3370      *
3371      * If an object is provided for `callback` the created "_.where" style callback
3372      * will return `true` for elements that have the properties of the given object,
3373      * else `false`.
3374      *
3375      * @static
3376      * @memberOf _
3377      * @category Collections
3378      * @param {Array|Object|string} collection The collection to iterate over.
3379      * @param {Function|Object|string} [callback=identity] The function called
3380      *  per iteration. If a property name or object is provided it will be used
3381      *  to create a "_.pluck" or "_.where" style callback, respectively.
3382      * @param {*} [thisArg] The `this` binding of `callback`.
3383      * @returns {Object} Returns the composed aggregate object.
3384      * @example
3385      *
3386      * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
3387      * // => { '4': 1, '6': 2 }
3388      *
3389      * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
3390      * // => { '4': 1, '6': 2 }
3391      *
3392      * _.countBy(['one', 'two', 'three'], 'length');
3393      * // => { '3': 2, '5': 1 }
3394      */
3395     var countBy = createAggregator(function(result, value, key) {
3396       (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
3397     });
3398
3399     /**
3400      * Checks if the given callback returns truey value for **all** elements of
3401      * a collection. The callback is bound to `thisArg` and invoked with three
3402      * arguments; (value, index|key, collection).
3403      *
3404      * If a property name is provided for `callback` the created "_.pluck" style
3405      * callback will return the property value of the given element.
3406      *
3407      * If an object is provided for `callback` the created "_.where" style callback
3408      * will return `true` for elements that have the properties of the given object,
3409      * else `false`.
3410      *
3411      * @static
3412      * @memberOf _
3413      * @alias all
3414      * @category Collections
3415      * @param {Array|Object|string} collection The collection to iterate over.
3416      * @param {Function|Object|string} [callback=identity] The function called
3417      *  per iteration. If a property name or object is provided it will be used
3418      *  to create a "_.pluck" or "_.where" style callback, respectively.
3419      * @param {*} [thisArg] The `this` binding of `callback`.
3420      * @returns {boolean} Returns `true` if all elements passed the callback check,
3421      *  else `false`.
3422      * @example
3423      *
3424      * _.every([true, 1, null, 'yes']);
3425      * // => false
3426      *
3427      * var characters = [
3428      *   { 'name': 'barney', 'age': 36 },
3429      *   { 'name': 'fred',   'age': 40 }
3430      * ];
3431      *
3432      * // using "_.pluck" callback shorthand
3433      * _.every(characters, 'age');
3434      * // => true
3435      *
3436      * // using "_.where" callback shorthand
3437      * _.every(characters, { 'age': 36 });
3438      * // => false
3439      */
3440     function every(collection, callback, thisArg) {
3441       var result = true;
3442       callback = lodash.createCallback(callback, thisArg, 3);
3443
3444       if (isArray(collection)) {
3445         var index = -1,
3446             length = collection.length;
3447
3448         while (++index < length) {
3449           if (!(result = !!callback(collection[index], index, collection))) {
3450             break;
3451           }
3452         }
3453       } else {
3454         baseEach(collection, function(value, index, collection) {
3455           return (result = !!callback(value, index, collection));
3456         });
3457       }
3458       return result;
3459     }
3460
3461     /**
3462      * Iterates over elements of a collection, returning an array of all elements
3463      * the callback returns truey for. The callback is bound to `thisArg` and
3464      * invoked with three arguments; (value, index|key, collection).
3465      *
3466      * If a property name is provided for `callback` the created "_.pluck" style
3467      * callback will return the property value of the given element.
3468      *
3469      * If an object is provided for `callback` the created "_.where" style callback
3470      * will return `true` for elements that have the properties of the given object,
3471      * else `false`.
3472      *
3473      * @static
3474      * @memberOf _
3475      * @alias select
3476      * @category Collections
3477      * @param {Array|Object|string} collection The collection to iterate over.
3478      * @param {Function|Object|string} [callback=identity] The function called
3479      *  per iteration. If a property name or object is provided it will be used
3480      *  to create a "_.pluck" or "_.where" style callback, respectively.
3481      * @param {*} [thisArg] The `this` binding of `callback`.
3482      * @returns {Array} Returns a new array of elements that passed the callback check.
3483      * @example
3484      *
3485      * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
3486      * // => [2, 4, 6]
3487      *
3488      * var characters = [
3489      *   { 'name': 'barney', 'age': 36, 'blocked': false },
3490      *   { 'name': 'fred',   'age': 40, 'blocked': true }
3491      * ];
3492      *
3493      * // using "_.pluck" callback shorthand
3494      * _.filter(characters, 'blocked');
3495      * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
3496      *
3497      * // using "_.where" callback shorthand
3498      * _.filter(characters, { 'age': 36 });
3499      * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
3500      */
3501     function filter(collection, callback, thisArg) {
3502       var result = [];
3503       callback = lodash.createCallback(callback, thisArg, 3);
3504
3505       if (isArray(collection)) {
3506         var index = -1,
3507             length = collection.length;
3508
3509         while (++index < length) {
3510           var value = collection[index];
3511           if (callback(value, index, collection)) {
3512             result.push(value);
3513           }
3514         }
3515       } else {
3516         baseEach(collection, function(value, index, collection) {
3517           if (callback(value, index, collection)) {
3518             result.push(value);
3519           }
3520         });
3521       }
3522       return result;
3523     }
3524
3525     /**
3526      * Iterates over elements of a collection, returning the first element that
3527      * the callback returns truey for. The callback is bound to `thisArg` and
3528      * invoked with three arguments; (value, index|key, collection).
3529      *
3530      * If a property name is provided for `callback` the created "_.pluck" style
3531      * callback will return the property value of the given element.
3532      *
3533      * If an object is provided for `callback` the created "_.where" style callback
3534      * will return `true` for elements that have the properties of the given object,
3535      * else `false`.
3536      *
3537      * @static
3538      * @memberOf _
3539      * @alias detect, findWhere
3540      * @category Collections
3541      * @param {Array|Object|string} collection The collection to iterate over.
3542      * @param {Function|Object|string} [callback=identity] The function called
3543      *  per iteration. If a property name or object is provided it will be used
3544      *  to create a "_.pluck" or "_.where" style callback, respectively.
3545      * @param {*} [thisArg] The `this` binding of `callback`.
3546      * @returns {*} Returns the found element, else `undefined`.
3547      * @example
3548      *
3549      * var characters = [
3550      *   { 'name': 'barney',  'age': 36, 'blocked': false },
3551      *   { 'name': 'fred',    'age': 40, 'blocked': true },
3552      *   { 'name': 'pebbles', 'age': 1,  'blocked': false }
3553      * ];
3554      *
3555      * _.find(characters, function(chr) {
3556      *   return chr.age < 40;
3557      * });
3558      * // => { 'name': 'barney', 'age': 36, 'blocked': false }
3559      *
3560      * // using "_.where" callback shorthand
3561      * _.find(characters, { 'age': 1 });
3562      * // =>  { 'name': 'pebbles', 'age': 1, 'blocked': false }
3563      *
3564      * // using "_.pluck" callback shorthand
3565      * _.find(characters, 'blocked');
3566      * // => { 'name': 'fred', 'age': 40, 'blocked': true }
3567      */
3568     function find(collection, callback, thisArg) {
3569       callback = lodash.createCallback(callback, thisArg, 3);
3570
3571       if (isArray(collection)) {
3572         var index = -1,
3573             length = collection.length;
3574
3575         while (++index < length) {
3576           var value = collection[index];
3577           if (callback(value, index, collection)) {
3578             return value;
3579           }
3580         }
3581       } else {
3582         var result;
3583         baseEach(collection, function(value, index, collection) {
3584           if (callback(value, index, collection)) {
3585             result = value;
3586             return false;
3587           }
3588         });
3589         return result;
3590       }
3591     }
3592
3593     /**
3594      * This method is like `_.find` except that it iterates over elements
3595      * of a `collection` from right to left.
3596      *
3597      * @static
3598      * @memberOf _
3599      * @category Collections
3600      * @param {Array|Object|string} collection The collection to iterate over.
3601      * @param {Function|Object|string} [callback=identity] The function called
3602      *  per iteration. If a property name or object is provided it will be used
3603      *  to create a "_.pluck" or "_.where" style callback, respectively.
3604      * @param {*} [thisArg] The `this` binding of `callback`.
3605      * @returns {*} Returns the found element, else `undefined`.
3606      * @example
3607      *
3608      * _.findLast([1, 2, 3, 4], function(num) {
3609      *   return num % 2 == 1;
3610      * });
3611      * // => 3
3612      */
3613     function findLast(collection, callback, thisArg) {
3614       var result;
3615       callback = lodash.createCallback(callback, thisArg, 3);
3616       forEachRight(collection, function(value, index, collection) {
3617         if (callback(value, index, collection)) {
3618           result = value;
3619           return false;
3620         }
3621       });
3622       return result;
3623     }
3624
3625     /**
3626      * Iterates over elements of a collection, executing the callback for each
3627      * element. The callback is bound to `thisArg` and invoked with three arguments;
3628      * (value, index|key, collection). Callbacks may exit iteration early by
3629      * explicitly returning `false`.
3630      *
3631      * Note: As with other "Collections" methods, objects with a `length` property
3632      * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
3633      * may be used for object iteration.
3634      *
3635      * @static
3636      * @memberOf _
3637      * @alias each
3638      * @category Collections
3639      * @param {Array|Object|string} collection The collection to iterate over.
3640      * @param {Function} [callback=identity] The function called per iteration.
3641      * @param {*} [thisArg] The `this` binding of `callback`.
3642      * @returns {Array|Object|string} Returns `collection`.
3643      * @example
3644      *
3645      * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(',');
3646      * // => logs each number and returns '1,2,3'
3647      *
3648      * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
3649      * // => logs each number and returns the object (property order is not guaranteed across environments)
3650      */
3651     function forEach(collection, callback, thisArg) {
3652       if (callback && typeof thisArg == 'undefined' && isArray(collection)) {
3653         var index = -1,
3654             length = collection.length;
3655
3656         while (++index < length) {
3657           if (callback(collection[index], index, collection) === false) {
3658             break;
3659           }
3660         }
3661       } else {
3662         baseEach(collection, callback, thisArg);
3663       }
3664       return collection;
3665     }
3666
3667     /**
3668      * This method is like `_.forEach` except that it iterates over elements
3669      * of a `collection` from right to left.
3670      *
3671      * @static
3672      * @memberOf _
3673      * @alias eachRight
3674      * @category Collections
3675      * @param {Array|Object|string} collection The collection to iterate over.
3676      * @param {Function} [callback=identity] The function called per iteration.
3677      * @param {*} [thisArg] The `this` binding of `callback`.
3678      * @returns {Array|Object|string} Returns `collection`.
3679      * @example
3680      *
3681      * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
3682      * // => logs each number from right to left and returns '3,2,1'
3683      */
3684     function forEachRight(collection, callback, thisArg) {
3685       var iterable = collection,
3686           length = collection ? collection.length : 0;
3687
3688       callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
3689       if (isArray(collection)) {
3690         while (length--) {
3691           if (callback(collection[length], length, collection) === false) {
3692             break;
3693           }
3694         }
3695       } else {
3696         if (typeof length != 'number') {
3697           var props = keys(collection);
3698           length = props.length;
3699         } else if (support.unindexedChars && isString(collection)) {
3700           iterable = collection.split('');
3701         }
3702         baseEach(collection, function(value, key, collection) {
3703           key = props ? props[--length] : --length;
3704           return callback(iterable[key], key, collection);
3705         });
3706       }
3707       return collection;
3708     }
3709
3710     /**
3711      * Creates an object composed of keys generated from the results of running
3712      * each element of a collection through the callback. The corresponding value
3713      * of each key is an array of the elements responsible for generating the key.
3714      * The callback is bound to `thisArg` and invoked with three arguments;
3715      * (value, index|key, collection).
3716      *
3717      * If a property name is provided for `callback` the created "_.pluck" style
3718      * callback will return the property value of the given element.
3719      *
3720      * If an object is provided for `callback` the created "_.where" style callback
3721      * will return `true` for elements that have the properties of the given object,
3722      * else `false`
3723      *
3724      * @static
3725      * @memberOf _
3726      * @category Collections
3727      * @param {Array|Object|string} collection The collection to iterate over.
3728      * @param {Function|Object|string} [callback=identity] The function called
3729      *  per iteration. If a property name or object is provided it will be used
3730      *  to create a "_.pluck" or "_.where" style callback, respectively.
3731      * @param {*} [thisArg] The `this` binding of `callback`.
3732      * @returns {Object} Returns the composed aggregate object.
3733      * @example
3734      *
3735      * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
3736      * // => { '4': [4.2], '6': [6.1, 6.4] }
3737      *
3738      * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
3739      * // => { '4': [4.2], '6': [6.1, 6.4] }
3740      *
3741      * // using "_.pluck" callback shorthand
3742      * _.groupBy(['one', 'two', 'three'], 'length');
3743      * // => { '3': ['one', 'two'], '5': ['three'] }
3744      */
3745     var groupBy = createAggregator(function(result, value, key) {
3746       (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
3747     });
3748
3749     /**
3750      * Creates an object composed of keys generated from the results of running
3751      * each element of the collection through the given callback. The corresponding
3752      * value of each key is the last element responsible for generating the key.
3753      * The callback is bound to `thisArg` and invoked with three arguments;
3754      * (value, index|key, collection).
3755      *
3756      * If a property name is provided for `callback` the created "_.pluck" style
3757      * callback will return the property value of the given element.
3758      *
3759      * If an object is provided for `callback` the created "_.where" style callback
3760      * will return `true` for elements that have the properties of the given object,
3761      * else `false`.
3762      *
3763      * @static
3764      * @memberOf _
3765      * @category Collections
3766      * @param {Array|Object|string} collection The collection to iterate over.
3767      * @param {Function|Object|string} [callback=identity] The function called
3768      *  per iteration. If a property name or object is provided it will be used
3769      *  to create a "_.pluck" or "_.where" style callback, respectively.
3770      * @param {*} [thisArg] The `this` binding of `callback`.
3771      * @returns {Object} Returns the composed aggregate object.
3772      * @example
3773      *
3774      * var keys = [
3775      *   { 'dir': 'left', 'code': 97 },
3776      *   { 'dir': 'right', 'code': 100 }
3777      * ];
3778      *
3779      * _.indexBy(keys, 'dir');
3780      * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
3781      *
3782      * _.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
3783      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
3784      *
3785      * _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
3786      * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
3787      */
3788     var indexBy = createAggregator(function(result, value, key) {
3789       result[key] = value;
3790     });
3791
3792     /**
3793      * Invokes the method named by `methodName` on each element in the `collection`
3794      * returning an array of the results of each invoked method. Additional arguments
3795      * will be provided to each invoked method. If `methodName` is a function it
3796      * will be invoked for, and `this` bound to, each element in the `collection`.
3797      *
3798      * @static
3799      * @memberOf _
3800      * @category Collections
3801      * @param {Array|Object|string} collection The collection to iterate over.
3802      * @param {Function|string} methodName The name of the method to invoke or
3803      *  the function invoked per iteration.
3804      * @param {...*} [arg] Arguments to invoke the method with.
3805      * @returns {Array} Returns a new array of the results of each invoked method.
3806      * @example
3807      *
3808      * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
3809      * // => [[1, 5, 7], [1, 2, 3]]
3810      *
3811      * _.invoke([123, 456], String.prototype.split, '');
3812      * // => [['1', '2', '3'], ['4', '5', '6']]
3813      */
3814     function invoke(collection, methodName) {
3815       var args = slice(arguments, 2),
3816           index = -1,
3817           isFunc = typeof methodName == 'function',
3818           length = collection ? collection.length : 0,
3819           result = Array(typeof length == 'number' ? length : 0);
3820
3821       forEach(collection, function(value) {
3822         result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
3823       });
3824       return result;
3825     }
3826
3827     /**
3828      * Creates an array of values by running each element in the collection
3829      * through the callback. The callback is bound to `thisArg` and invoked with
3830      * three arguments; (value, index|key, collection).
3831      *
3832      * If a property name is provided for `callback` the created "_.pluck" style
3833      * callback will return the property value of the given element.
3834      *
3835      * If an object is provided for `callback` the created "_.where" style callback
3836      * will return `true` for elements that have the properties of the given object,
3837      * else `false`.
3838      *
3839      * @static
3840      * @memberOf _
3841      * @alias collect
3842      * @category Collections
3843      * @param {Array|Object|string} collection The collection to iterate over.
3844      * @param {Function|Object|string} [callback=identity] The function called
3845      *  per iteration. If a property name or object is provided it will be used
3846      *  to create a "_.pluck" or "_.where" style callback, respectively.
3847      * @param {*} [thisArg] The `this` binding of `callback`.
3848      * @returns {Array} Returns a new array of the results of each `callback` execution.
3849      * @example
3850      *
3851      * _.map([1, 2, 3], function(num) { return num * 3; });
3852      * // => [3, 6, 9]
3853      *
3854      * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
3855      * // => [3, 6, 9] (property order is not guaranteed across environments)
3856      *
3857      * var characters = [
3858      *   { 'name': 'barney', 'age': 36 },
3859      *   { 'name': 'fred',   'age': 40 }
3860      * ];
3861      *
3862      * // using "_.pluck" callback shorthand
3863      * _.map(characters, 'name');
3864      * // => ['barney', 'fred']
3865      */
3866     function map(collection, callback, thisArg) {
3867       var index = -1,
3868           length = collection ? collection.length : 0,
3869           result = Array(typeof length == 'number' ? length : 0);
3870
3871       callback = lodash.createCallback(callback, thisArg, 3);
3872       if (isArray(collection)) {
3873         while (++index < length) {
3874           result[index] = callback(collection[index], index, collection);
3875         }
3876       } else {
3877         baseEach(collection, function(value, key, collection) {
3878           result[++index] = callback(value, key, collection);
3879         });
3880       }
3881       return result;
3882     }
3883
3884     /**
3885      * Retrieves the maximum value of a collection. If the collection is empty or
3886      * falsey `-Infinity` is returned. If a callback is provided it will be executed
3887      * for each value in the collection to generate the criterion by which the value
3888      * is ranked. The callback is bound to `thisArg` and invoked with three
3889      * arguments; (value, index, collection).
3890      *
3891      * If a property name is provided for `callback` the created "_.pluck" style
3892      * callback will return the property value of the given element.
3893      *
3894      * If an object is provided for `callback` the created "_.where" style callback
3895      * will return `true` for elements that have the properties of the given object,
3896      * else `false`.
3897      *
3898      * @static
3899      * @memberOf _
3900      * @category Collections
3901      * @param {Array|Object|string} collection The collection to iterate over.
3902      * @param {Function|Object|string} [callback=identity] The function called
3903      *  per iteration. If a property name or object is provided it will be used
3904      *  to create a "_.pluck" or "_.where" style callback, respectively.
3905      * @param {*} [thisArg] The `this` binding of `callback`.
3906      * @returns {*} Returns the maximum value.
3907      * @example
3908      *
3909      * _.max([4, 2, 8, 6]);
3910      * // => 8
3911      *
3912      * var characters = [
3913      *   { 'name': 'barney', 'age': 36 },
3914      *   { 'name': 'fred',   'age': 40 }
3915      * ];
3916      *
3917      * _.max(characters, function(chr) { return chr.age; });
3918      * // => { 'name': 'fred', 'age': 40 };
3919      *
3920      * // using "_.pluck" callback shorthand
3921      * _.max(characters, 'age');
3922      * // => { 'name': 'fred', 'age': 40 };
3923      */
3924     function max(collection, callback, thisArg) {
3925       var computed = -Infinity,
3926           result = computed;
3927
3928       // allows working with functions like `_.map` without using
3929       // their `index` argument as a callback
3930       if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
3931         callback = null;
3932       }
3933       if (callback == null && isArray(collection)) {
3934         var index = -1,
3935             length = collection.length;
3936
3937         while (++index < length) {
3938           var value = collection[index];
3939           if (value > result) {
3940             result = value;
3941           }
3942         }
3943       } else {
3944         callback = (callback == null && isString(collection))
3945           ? charAtCallback
3946           : lodash.createCallback(callback, thisArg, 3);
3947
3948         baseEach(collection, function(value, index, collection) {
3949           var current = callback(value, index, collection);
3950           if (current > computed) {
3951             computed = current;
3952             result = value;
3953           }
3954         });
3955       }
3956       return result;
3957     }
3958
3959     /**
3960      * Retrieves the minimum value of a collection. If the collection is empty or
3961      * falsey `Infinity` is returned. If a callback is provided it will be executed
3962      * for each value in the collection to generate the criterion by which the value
3963      * is ranked. The callback is bound to `thisArg` and invoked with three
3964      * arguments; (value, index, collection).
3965      *
3966      * If a property name is provided for `callback` the created "_.pluck" style
3967      * callback will return the property value of the given element.
3968      *
3969      * If an object is provided for `callback` the created "_.where" style callback
3970      * will return `true` for elements that have the properties of the given object,
3971      * else `false`.
3972      *
3973      * @static
3974      * @memberOf _
3975      * @category Collections
3976      * @param {Array|Object|string} collection The collection to iterate over.
3977      * @param {Function|Object|string} [callback=identity] The function called
3978      *  per iteration. If a property name or object is provided it will be used
3979      *  to create a "_.pluck" or "_.where" style callback, respectively.
3980      * @param {*} [thisArg] The `this` binding of `callback`.
3981      * @returns {*} Returns the minimum value.
3982      * @example
3983      *
3984      * _.min([4, 2, 8, 6]);
3985      * // => 2
3986      *
3987      * var characters = [
3988      *   { 'name': 'barney', 'age': 36 },
3989      *   { 'name': 'fred',   'age': 40 }
3990      * ];
3991      *
3992      * _.min(characters, function(chr) { return chr.age; });
3993      * // => { 'name': 'barney', 'age': 36 };
3994      *
3995      * // using "_.pluck" callback shorthand
3996      * _.min(characters, 'age');
3997      * // => { 'name': 'barney', 'age': 36 };
3998      */
3999     function min(collection, callback, thisArg) {
4000       var computed = Infinity,
4001           result = computed;
4002
4003       // allows working with functions like `_.map` without using
4004       // their `index` argument as a callback
4005       if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
4006         callback = null;
4007       }
4008       if (callback == null && isArray(collection)) {
4009         var index = -1,
4010             length = collection.length;
4011
4012         while (++index < length) {
4013           var value = collection[index];
4014           if (value < result) {
4015             result = value;
4016           }
4017         }
4018       } else {
4019         callback = (callback == null && isString(collection))
4020           ? charAtCallback
4021           : lodash.createCallback(callback, thisArg, 3);
4022
4023         baseEach(collection, function(value, index, collection) {
4024           var current = callback(value, index, collection);
4025           if (current < computed) {
4026             computed = current;
4027             result = value;
4028           }
4029         });
4030       }
4031       return result;
4032     }
4033
4034     /**
4035      * Retrieves the value of a specified property from all elements in the collection.
4036      *
4037      * @static
4038      * @memberOf _
4039      * @type Function
4040      * @category Collections
4041      * @param {Array|Object|string} collection The collection to iterate over.
4042      * @param {string} property The name of the property to pluck.
4043      * @returns {Array} Returns a new array of property values.
4044      * @example
4045      *
4046      * var characters = [
4047      *   { 'name': 'barney', 'age': 36 },
4048      *   { 'name': 'fred',   'age': 40 }
4049      * ];
4050      *
4051      * _.pluck(characters, 'name');
4052      * // => ['barney', 'fred']
4053      */
4054     var pluck = map;
4055
4056     /**
4057      * Reduces a collection to a value which is the accumulated result of running
4058      * each element in the collection through the callback, where each successive
4059      * callback execution consumes the return value of the previous execution. If
4060      * `accumulator` is not provided the first element of the collection will be
4061      * used as the initial `accumulator` value. The callback is bound to `thisArg`
4062      * and invoked with four arguments; (accumulator, value, index|key, collection).
4063      *
4064      * @static
4065      * @memberOf _
4066      * @alias foldl, inject
4067      * @category Collections
4068      * @param {Array|Object|string} collection The collection to iterate over.
4069      * @param {Function} [callback=identity] The function called per iteration.
4070      * @param {*} [accumulator] Initial value of the accumulator.
4071      * @param {*} [thisArg] The `this` binding of `callback`.
4072      * @returns {*} Returns the accumulated value.
4073      * @example
4074      *
4075      * var sum = _.reduce([1, 2, 3], function(sum, num) {
4076      *   return sum + num;
4077      * });
4078      * // => 6
4079      *
4080      * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
4081      *   result[key] = num * 3;
4082      *   return result;
4083      * }, {});
4084      * // => { 'a': 3, 'b': 6, 'c': 9 }
4085      */
4086     function reduce(collection, callback, accumulator, thisArg) {
4087       var noaccum = arguments.length < 3;
4088       callback = lodash.createCallback(callback, thisArg, 4);
4089
4090       if (isArray(collection)) {
4091         var index = -1,
4092             length = collection.length;
4093
4094         if (noaccum) {
4095           accumulator = collection[++index];
4096         }
4097         while (++index < length) {
4098           accumulator = callback(accumulator, collection[index], index, collection);
4099         }
4100       } else {
4101         baseEach(collection, function(value, index, collection) {
4102           accumulator = noaccum
4103             ? (noaccum = false, value)
4104             : callback(accumulator, value, index, collection)
4105         });
4106       }
4107       return accumulator;
4108     }
4109
4110     /**
4111      * This method is like `_.reduce` except that it iterates over elements
4112      * of a `collection` from right to left.
4113      *
4114      * @static
4115      * @memberOf _
4116      * @alias foldr
4117      * @category Collections
4118      * @param {Array|Object|string} collection The collection to iterate over.
4119      * @param {Function} [callback=identity] The function called per iteration.
4120      * @param {*} [accumulator] Initial value of the accumulator.
4121      * @param {*} [thisArg] The `this` binding of `callback`.
4122      * @returns {*} Returns the accumulated value.
4123      * @example
4124      *
4125      * var list = [[0, 1], [2, 3], [4, 5]];
4126      * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
4127      * // => [4, 5, 2, 3, 0, 1]
4128      */
4129     function reduceRight(collection, callback, accumulator, thisArg) {
4130       var noaccum = arguments.length < 3;
4131       callback = lodash.createCallback(callback, thisArg, 4);
4132       forEachRight(collection, function(value, index, collection) {
4133         accumulator = noaccum
4134           ? (noaccum = false, value)
4135           : callback(accumulator, value, index, collection);
4136       });
4137       return accumulator;
4138     }
4139
4140     /**
4141      * The opposite of `_.filter` this method returns the elements of a
4142      * collection that the callback does **not** return truey for.
4143      *
4144      * If a property name is provided for `callback` the created "_.pluck" style
4145      * callback will return the property value of the given element.
4146      *
4147      * If an object is provided for `callback` the created "_.where" style callback
4148      * will return `true` for elements that have the properties of the given object,
4149      * else `false`.
4150      *
4151      * @static
4152      * @memberOf _
4153      * @category Collections
4154      * @param {Array|Object|string} collection The collection to iterate over.
4155      * @param {Function|Object|string} [callback=identity] The function called
4156      *  per iteration. If a property name or object is provided it will be used
4157      *  to create a "_.pluck" or "_.where" style callback, respectively.
4158      * @param {*} [thisArg] The `this` binding of `callback`.
4159      * @returns {Array} Returns a new array of elements that failed the callback check.
4160      * @example
4161      *
4162      * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
4163      * // => [1, 3, 5]
4164      *
4165      * var characters = [
4166      *   { 'name': 'barney', 'age': 36, 'blocked': false },
4167      *   { 'name': 'fred',   'age': 40, 'blocked': true }
4168      * ];
4169      *
4170      * // using "_.pluck" callback shorthand
4171      * _.reject(characters, 'blocked');
4172      * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
4173      *
4174      * // using "_.where" callback shorthand
4175      * _.reject(characters, { 'age': 36 });
4176      * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
4177      */
4178     function reject(collection, callback, thisArg) {
4179       callback = lodash.createCallback(callback, thisArg, 3);
4180       return filter(collection, function(value, index, collection) {
4181         return !callback(value, index, collection);
4182       });
4183     }
4184
4185     /**
4186      * Retrieves a random element or `n` random elements from a collection.
4187      *
4188      * @static
4189      * @memberOf _
4190      * @category Collections
4191      * @param {Array|Object|string} collection The collection to sample.
4192      * @param {number} [n] The number of elements to sample.
4193      * @param- {Object} [guard] Allows working with functions like `_.map`
4194      *  without using their `index` arguments as `n`.
4195      * @returns {Array} Returns the random sample(s) of `collection`.
4196      * @example
4197      *
4198      * _.sample([1, 2, 3, 4]);
4199      * // => 2
4200      *
4201      * _.sample([1, 2, 3, 4], 2);
4202      * // => [3, 1]
4203      */
4204     function sample(collection, n, guard) {
4205       if (collection && typeof collection.length != 'number') {
4206         collection = values(collection);
4207       } else if (support.unindexedChars && isString(collection)) {
4208         collection = collection.split('');
4209       }
4210       if (n == null || guard) {
4211         return collection ? collection[baseRandom(0, collection.length - 1)] : undefined;
4212       }
4213       var result = shuffle(collection);
4214       result.length = nativeMin(nativeMax(0, n), result.length);
4215       return result;
4216     }
4217
4218     /**
4219      * Creates an array of shuffled values, using a version of the Fisher-Yates
4220      * shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
4221      *
4222      * @static
4223      * @memberOf _
4224      * @category Collections
4225      * @param {Array|Object|string} collection The collection to shuffle.
4226      * @returns {Array} Returns a new shuffled collection.
4227      * @example
4228      *
4229      * _.shuffle([1, 2, 3, 4, 5, 6]);
4230      * // => [4, 1, 6, 3, 5, 2]
4231      */
4232     function shuffle(collection) {
4233       var index = -1,
4234           length = collection ? collection.length : 0,
4235           result = Array(typeof length == 'number' ? length : 0);
4236
4237       forEach(collection, function(value) {
4238         var rand = baseRandom(0, ++index);
4239         result[index] = result[rand];
4240         result[rand] = value;
4241       });
4242       return result;
4243     }
4244
4245     /**
4246      * Gets the size of the `collection` by returning `collection.length` for arrays
4247      * and array-like objects or the number of own enumerable properties for objects.
4248      *
4249      * @static
4250      * @memberOf _
4251      * @category Collections
4252      * @param {Array|Object|string} collection The collection to inspect.
4253      * @returns {number} Returns `collection.length` or number of own enumerable properties.
4254      * @example
4255      *
4256      * _.size([1, 2]);
4257      * // => 2
4258      *
4259      * _.size({ 'one': 1, 'two': 2, 'three': 3 });
4260      * // => 3
4261      *
4262      * _.size('pebbles');
4263      * // => 7
4264      */
4265     function size(collection) {
4266       var length = collection ? collection.length : 0;
4267       return typeof length == 'number' ? length : keys(collection).length;
4268     }
4269
4270     /**
4271      * Checks if the callback returns a truey value for **any** element of a
4272      * collection. The function returns as soon as it finds a passing value and
4273      * does not iterate over the entire collection. The callback is bound to
4274      * `thisArg` and invoked with three arguments; (value, index|key, collection).
4275      *
4276      * If a property name is provided for `callback` the created "_.pluck" style
4277      * callback will return the property value of the given element.
4278      *
4279      * If an object is provided for `callback` the created "_.where" style callback
4280      * will return `true` for elements that have the properties of the given object,
4281      * else `false`.
4282      *
4283      * @static
4284      * @memberOf _
4285      * @alias any
4286      * @category Collections
4287      * @param {Array|Object|string} collection The collection to iterate over.
4288      * @param {Function|Object|string} [callback=identity] The function called
4289      *  per iteration. If a property name or object is provided it will be used
4290      *  to create a "_.pluck" or "_.where" style callback, respectively.
4291      * @param {*} [thisArg] The `this` binding of `callback`.
4292      * @returns {boolean} Returns `true` if any element passed the callback check,
4293      *  else `false`.
4294      * @example
4295      *
4296      * _.some([null, 0, 'yes', false], Boolean);
4297      * // => true
4298      *
4299      * var characters = [
4300      *   { 'name': 'barney', 'age': 36, 'blocked': false },
4301      *   { 'name': 'fred',   'age': 40, 'blocked': true }
4302      * ];
4303      *
4304      * // using "_.pluck" callback shorthand
4305      * _.some(characters, 'blocked');
4306      * // => true
4307      *
4308      * // using "_.where" callback shorthand
4309      * _.some(characters, { 'age': 1 });
4310      * // => false
4311      */
4312     function some(collection, callback, thisArg) {
4313       var result;
4314       callback = lodash.createCallback(callback, thisArg, 3);
4315
4316       if (isArray(collection)) {
4317         var index = -1,
4318             length = collection.length;
4319
4320         while (++index < length) {
4321           if ((result = callback(collection[index], index, collection))) {
4322             break;
4323           }
4324         }
4325       } else {
4326         baseEach(collection, function(value, index, collection) {
4327           return !(result = callback(value, index, collection));
4328         });
4329       }
4330       return !!result;
4331     }
4332
4333     /**
4334      * Creates an array of elements, sorted in ascending order by the results of
4335      * running each element in a collection through the callback. This method
4336      * performs a stable sort, that is, it will preserve the original sort order
4337      * of equal elements. The callback is bound to `thisArg` and invoked with
4338      * three arguments; (value, index|key, collection).
4339      *
4340      * If a property name is provided for `callback` the created "_.pluck" style
4341      * callback will return the property value of the given element.
4342      *
4343      * If an array of property names is provided for `callback` the collection
4344      * will be sorted by each property value.
4345      *
4346      * If an object is provided for `callback` the created "_.where" style callback
4347      * will return `true` for elements that have the properties of the given object,
4348      * else `false`.
4349      *
4350      * @static
4351      * @memberOf _
4352      * @category Collections
4353      * @param {Array|Object|string} collection The collection to iterate over.
4354      * @param {Array|Function|Object|string} [callback=identity] The function called
4355      *  per iteration. If a property name or object is provided it will be used
4356      *  to create a "_.pluck" or "_.where" style callback, respectively.
4357      * @param {*} [thisArg] The `this` binding of `callback`.
4358      * @returns {Array} Returns a new array of sorted elements.
4359      * @example
4360      *
4361      * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
4362      * // => [3, 1, 2]
4363      *
4364      * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
4365      * // => [3, 1, 2]
4366      *
4367      * var characters = [
4368      *   { 'name': 'barney',  'age': 36 },
4369      *   { 'name': 'fred',    'age': 40 },
4370      *   { 'name': 'barney',  'age': 26 },
4371      *   { 'name': 'fred',    'age': 30 }
4372      * ];
4373      *
4374      * // using "_.pluck" callback shorthand
4375      * _.map(_.sortBy(characters, 'age'), _.values);
4376      * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
4377      *
4378      * // sorting by multiple properties
4379      * _.map(_.sortBy(characters, ['name', 'age']), _.values);
4380      * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
4381      */
4382     function sortBy(collection, callback, thisArg) {
4383       var index = -1,
4384           isArr = isArray(callback),
4385           length = collection ? collection.length : 0,
4386           result = Array(typeof length == 'number' ? length : 0);
4387
4388       if (!isArr) {
4389         callback = lodash.createCallback(callback, thisArg, 3);
4390       }
4391       forEach(collection, function(value, key, collection) {
4392         var object = result[++index] = getObject();
4393         if (isArr) {
4394           object.criteria = map(callback, function(key) { return value[key]; });
4395         } else {
4396           (object.criteria = getArray())[0] = callback(value, key, collection);
4397         }
4398         object.index = index;
4399         object.value = value;
4400       });
4401
4402       length = result.length;
4403       result.sort(compareAscending);
4404       while (length--) {
4405         var object = result[length];
4406         result[length] = object.value;
4407         if (!isArr) {
4408           releaseArray(object.criteria);
4409         }
4410         releaseObject(object);
4411       }
4412       return result;
4413     }
4414
4415     /**
4416      * Converts the `collection` to an array.
4417      *
4418      * @static
4419      * @memberOf _
4420      * @category Collections
4421      * @param {Array|Object|string} collection The collection to convert.
4422      * @returns {Array} Returns the new converted array.
4423      * @example
4424      *
4425      * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
4426      * // => [2, 3, 4]
4427      */
4428     function toArray(collection) {
4429       if (collection && typeof collection.length == 'number') {
4430         return (support.unindexedChars && isString(collection))
4431           ? collection.split('')
4432           : slice(collection);
4433       }
4434       return values(collection);
4435     }
4436
4437     /**
4438      * Performs a deep comparison of each element in a `collection` to the given
4439      * `properties` object, returning an array of all elements that have equivalent
4440      * property values.
4441      *
4442      * @static
4443      * @memberOf _
4444      * @type Function
4445      * @category Collections
4446      * @param {Array|Object|string} collection The collection to iterate over.
4447      * @param {Object} props The object of property values to filter by.
4448      * @returns {Array} Returns a new array of elements that have the given properties.
4449      * @example
4450      *
4451      * var characters = [
4452      *   { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] },
4453      *   { 'name': 'fred',   'age': 40, 'pets': ['baby puss', 'dino'] }
4454      * ];
4455      *
4456      * _.where(characters, { 'age': 36 });
4457      * // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }]
4458      *
4459      * _.where(characters, { 'pets': ['dino'] });
4460      * // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }]
4461      */
4462     var where = filter;
4463
4464     /*--------------------------------------------------------------------------*/
4465
4466     /**
4467      * Creates an array with all falsey values removed. The values `false`, `null`,
4468      * `0`, `""`, `undefined`, and `NaN` are all falsey.
4469      *
4470      * @static
4471      * @memberOf _
4472      * @category Arrays
4473      * @param {Array} array The array to compact.
4474      * @returns {Array} Returns a new array of filtered values.
4475      * @example
4476      *
4477      * _.compact([0, 1, false, 2, '', 3]);
4478      * // => [1, 2, 3]
4479      */
4480     function compact(array) {
4481       var index = -1,
4482           length = array ? array.length : 0,
4483           result = [];
4484
4485       while (++index < length) {
4486         var value = array[index];
4487         if (value) {
4488           result.push(value);
4489         }
4490       }
4491       return result;
4492     }
4493
4494     /**
4495      * Creates an array excluding all values of the provided arrays using strict
4496      * equality for comparisons, i.e. `===`.
4497      *
4498      * @static
4499      * @memberOf _
4500      * @category Arrays
4501      * @param {Array} array The array to process.
4502      * @param {...Array} [values] The arrays of values to exclude.
4503      * @returns {Array} Returns a new array of filtered values.
4504      * @example
4505      *
4506      * _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
4507      * // => [1, 3, 4]
4508      */
4509     function difference(array) {
4510       return baseDifference(array, baseFlatten(arguments, true, true, 1));
4511     }
4512
4513     /**
4514      * This method is like `_.find` except that it returns the index of the first
4515      * element that passes the callback check, instead of the element itself.
4516      *
4517      * If a property name is provided for `callback` the created "_.pluck" style
4518      * callback will return the property value of the given element.
4519      *
4520      * If an object is provided for `callback` the created "_.where" style callback
4521      * will return `true` for elements that have the properties of the given object,
4522      * else `false`.
4523      *
4524      * @static
4525      * @memberOf _
4526      * @category Arrays
4527      * @param {Array} array The array to search.
4528      * @param {Function|Object|string} [callback=identity] The function called
4529      *  per iteration. If a property name or object is provided it will be used
4530      *  to create a "_.pluck" or "_.where" style callback, respectively.
4531      * @param {*} [thisArg] The `this` binding of `callback`.
4532      * @returns {number} Returns the index of the found element, else `-1`.
4533      * @example
4534      *
4535      * var characters = [
4536      *   { 'name': 'barney',  'age': 36, 'blocked': false },
4537      *   { 'name': 'fred',    'age': 40, 'blocked': true },
4538      *   { 'name': 'pebbles', 'age': 1,  'blocked': false }
4539      * ];
4540      *
4541      * _.findIndex(characters, function(chr) {
4542      *   return chr.age < 20;
4543      * });
4544      * // => 2
4545      *
4546      * // using "_.where" callback shorthand
4547      * _.findIndex(characters, { 'age': 36 });
4548      * // => 0
4549      *
4550      * // using "_.pluck" callback shorthand
4551      * _.findIndex(characters, 'blocked');
4552      * // => 1
4553      */
4554     function findIndex(array, callback, thisArg) {
4555       var index = -1,
4556           length = array ? array.length : 0;
4557
4558       callback = lodash.createCallback(callback, thisArg, 3);
4559       while (++index < length) {
4560         if (callback(array[index], index, array)) {
4561           return index;
4562         }
4563       }
4564       return -1;
4565     }
4566
4567     /**
4568      * This method is like `_.findIndex` except that it iterates over elements
4569      * of a `collection` from right to left.
4570      *
4571      * If a property name is provided for `callback` the created "_.pluck" style
4572      * callback will return the property value of the given element.
4573      *
4574      * If an object is provided for `callback` the created "_.where" style callback
4575      * will return `true` for elements that have the properties of the given object,
4576      * else `false`.
4577      *
4578      * @static
4579      * @memberOf _
4580      * @category Arrays
4581      * @param {Array} array The array to search.
4582      * @param {Function|Object|string} [callback=identity] The function called
4583      *  per iteration. If a property name or object is provided it will be used
4584      *  to create a "_.pluck" or "_.where" style callback, respectively.
4585      * @param {*} [thisArg] The `this` binding of `callback`.
4586      * @returns {number} Returns the index of the found element, else `-1`.
4587      * @example
4588      *
4589      * var characters = [
4590      *   { 'name': 'barney',  'age': 36, 'blocked': true },
4591      *   { 'name': 'fred',    'age': 40, 'blocked': false },
4592      *   { 'name': 'pebbles', 'age': 1,  'blocked': true }
4593      * ];
4594      *
4595      * _.findLastIndex(characters, function(chr) {
4596      *   return chr.age > 30;
4597      * });
4598      * // => 1
4599      *
4600      * // using "_.where" callback shorthand
4601      * _.findLastIndex(characters, { 'age': 36 });
4602      * // => 0
4603      *
4604      * // using "_.pluck" callback shorthand
4605      * _.findLastIndex(characters, 'blocked');
4606      * // => 2
4607      */
4608     function findLastIndex(array, callback, thisArg) {
4609       var length = array ? array.length : 0;
4610       callback = lodash.createCallback(callback, thisArg, 3);
4611       while (length--) {
4612         if (callback(array[length], length, array)) {
4613           return length;
4614         }
4615       }
4616       return -1;
4617     }
4618
4619     /**
4620      * Gets the first element or first `n` elements of an array. If a callback
4621      * is provided elements at the beginning of the array are returned as long
4622      * as the callback returns truey. The callback is bound to `thisArg` and
4623      * invoked with three arguments; (value, index, array).
4624      *
4625      * If a property name is provided for `callback` the created "_.pluck" style
4626      * callback will return the property value of the given element.
4627      *
4628      * If an object is provided for `callback` the created "_.where" style callback
4629      * will return `true` for elements that have the properties of the given object,
4630      * else `false`.
4631      *
4632      * @static
4633      * @memberOf _
4634      * @alias head, take
4635      * @category Arrays
4636      * @param {Array} array The array to query.
4637      * @param {Function|Object|number|string} [callback] The function called
4638      *  per element or the number of elements to return. If a property name or
4639      *  object is provided it will be used to create a "_.pluck" or "_.where"
4640      *  style callback, respectively.
4641      * @param {*} [thisArg] The `this` binding of `callback`.
4642      * @returns {*} Returns the first element(s) of `array`.
4643      * @example
4644      *
4645      * _.first([1, 2, 3]);
4646      * // => 1
4647      *
4648      * _.first([1, 2, 3], 2);
4649      * // => [1, 2]
4650      *
4651      * _.first([1, 2, 3], function(num) {
4652      *   return num < 3;
4653      * });
4654      * // => [1, 2]
4655      *
4656      * var characters = [
4657      *   { 'name': 'barney',  'blocked': true,  'employer': 'slate' },
4658      *   { 'name': 'fred',    'blocked': false, 'employer': 'slate' },
4659      *   { 'name': 'pebbles', 'blocked': true,  'employer': 'na' }
4660      * ];
4661      *
4662      * // using "_.pluck" callback shorthand
4663      * _.first(characters, 'blocked');
4664      * // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }]
4665      *
4666      * // using "_.where" callback shorthand
4667      * _.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
4668      * // => ['barney', 'fred']
4669      */
4670     function first(array, callback, thisArg) {
4671       var n = 0,
4672           length = array ? array.length : 0;
4673
4674       if (typeof callback != 'number' && callback != null) {
4675         var index = -1;
4676         callback = lodash.createCallback(callback, thisArg, 3);
4677         while (++index < length && callback(array[index], index, array)) {
4678           n++;
4679         }
4680       } else {
4681         n = callback;
4682         if (n == null || thisArg) {
4683           return array ? array[0] : undefined;
4684         }
4685       }
4686       return slice(array, 0, nativeMin(nativeMax(0, n), length));
4687     }
4688
4689     /**
4690      * Flattens a nested array (the nesting can be to any depth). If `isShallow`
4691      * is truey, the array will only be flattened a single level. If a callback
4692      * is provided each element of the array is passed through the callback before
4693      * flattening. The callback is bound to `thisArg` and invoked with three
4694      * arguments; (value, index, array).
4695      *
4696      * If a property name is provided for `callback` the created "_.pluck" style
4697      * callback will return the property value of the given element.
4698      *
4699      * If an object is provided for `callback` the created "_.where" style callback
4700      * will return `true` for elements that have the properties of the given object,
4701      * else `false`.
4702      *
4703      * @static
4704      * @memberOf _
4705      * @category Arrays
4706      * @param {Array} array The array to flatten.
4707      * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
4708      * @param {Function|Object|string} [callback=identity] The function called
4709      *  per iteration. If a property name or object is provided it will be used
4710      *  to create a "_.pluck" or "_.where" style callback, respectively.
4711      * @param {*} [thisArg] The `this` binding of `callback`.
4712      * @returns {Array} Returns a new flattened array.
4713      * @example
4714      *
4715      * _.flatten([1, [2], [3, [[4]]]]);
4716      * // => [1, 2, 3, 4];
4717      *
4718      * _.flatten([1, [2], [3, [[4]]]], true);
4719      * // => [1, 2, 3, [[4]]];
4720      *
4721      * var characters = [
4722      *   { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] },
4723      *   { 'name': 'fred',   'age': 40, 'pets': ['baby puss', 'dino'] }
4724      * ];
4725      *
4726      * // using "_.pluck" callback shorthand
4727      * _.flatten(characters, 'pets');
4728      * // => ['hoppy', 'baby puss', 'dino']
4729      */
4730     function flatten(array, isShallow, callback, thisArg) {
4731       // juggle arguments
4732       if (typeof isShallow != 'boolean' && isShallow != null) {
4733         thisArg = callback;
4734         callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow;
4735         isShallow = false;
4736       }
4737       if (callback != null) {
4738         array = map(array, callback, thisArg);
4739       }
4740       return baseFlatten(array, isShallow);
4741     }
4742
4743     /**
4744      * Gets the index at which the first occurrence of `value` is found using
4745      * strict equality for comparisons, i.e. `===`. If the array is already sorted
4746      * providing `true` for `fromIndex` will run a faster binary search.
4747      *
4748      * @static
4749      * @memberOf _
4750      * @category Arrays
4751      * @param {Array} array The array to search.
4752      * @param {*} value The value to search for.
4753      * @param {boolean|number} [fromIndex=0] The index to search from or `true`
4754      *  to perform a binary search on a sorted array.
4755      * @returns {number} Returns the index of the matched value or `-1`.
4756      * @example
4757      *
4758      * _.indexOf([1, 2, 3, 1, 2, 3], 2);
4759      * // => 1
4760      *
4761      * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
4762      * // => 4
4763      *
4764      * _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
4765      * // => 2
4766      */
4767     function indexOf(array, value, fromIndex) {
4768       if (typeof fromIndex == 'number') {
4769         var length = array ? array.length : 0;
4770         fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0);
4771       } else if (fromIndex) {
4772         var index = sortedIndex(array, value);
4773         return array[index] === value ? index : -1;
4774       }
4775       return baseIndexOf(array, value, fromIndex);
4776     }
4777
4778     /**
4779      * Gets all but the last element or last `n` elements of an array. If a
4780      * callback is provided elements at the end of the array are excluded from
4781      * the result as long as the callback returns truey. The callback is bound
4782      * to `thisArg` and invoked with three arguments; (value, index, array).
4783      *
4784      * If a property name is provided for `callback` the created "_.pluck" style
4785      * callback will return the property value of the given element.
4786      *
4787      * If an object is provided for `callback` the created "_.where" style callback
4788      * will return `true` for elements that have the properties of the given object,
4789      * else `false`.
4790      *
4791      * @static
4792      * @memberOf _
4793      * @category Arrays
4794      * @param {Array} array The array to query.
4795      * @param {Function|Object|number|string} [callback=1] The function called
4796      *  per element or the number of elements to exclude. If a property name or
4797      *  object is provided it will be used to create a "_.pluck" or "_.where"
4798      *  style callback, respectively.
4799      * @param {*} [thisArg] The `this` binding of `callback`.
4800      * @returns {Array} Returns a slice of `array`.
4801      * @example
4802      *
4803      * _.initial([1, 2, 3]);
4804      * // => [1, 2]
4805      *
4806      * _.initial([1, 2, 3], 2);
4807      * // => [1]
4808      *
4809      * _.initial([1, 2, 3], function(num) {
4810      *   return num > 1;
4811      * });
4812      * // => [1]
4813      *
4814      * var characters = [
4815      *   { 'name': 'barney',  'blocked': false, 'employer': 'slate' },
4816      *   { 'name': 'fred',    'blocked': true,  'employer': 'slate' },
4817      *   { 'name': 'pebbles', 'blocked': true,  'employer': 'na' }
4818      * ];
4819      *
4820      * // using "_.pluck" callback shorthand
4821      * _.initial(characters, 'blocked');
4822      * // => [{ 'name': 'barney',  'blocked': false, 'employer': 'slate' }]
4823      *
4824      * // using "_.where" callback shorthand
4825      * _.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
4826      * // => ['barney', 'fred']
4827      */
4828     function initial(array, callback, thisArg) {
4829       var n = 0,
4830           length = array ? array.length : 0;
4831
4832       if (typeof callback != 'number' && callback != null) {
4833         var index = length;
4834         callback = lodash.createCallback(callback, thisArg, 3);
4835         while (index-- && callback(array[index], index, array)) {
4836           n++;
4837         }
4838       } else {
4839         n = (callback == null || thisArg) ? 1 : callback || n;
4840       }
4841       return slice(array, 0, nativeMin(nativeMax(0, length - n), length));
4842     }
4843
4844     /**
4845      * Creates an array of unique values present in all provided arrays using
4846      * strict equality for comparisons, i.e. `===`.
4847      *
4848      * @static
4849      * @memberOf _
4850      * @category Arrays
4851      * @param {...Array} [array] The arrays to inspect.
4852      * @returns {Array} Returns an array of shared values.
4853      * @example
4854      *
4855      * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
4856      * // => [1, 2]
4857      */
4858     function intersection() {
4859       var args = [],
4860           argsIndex = -1,
4861           argsLength = arguments.length,
4862           caches = getArray(),
4863           indexOf = getIndexOf(),
4864           trustIndexOf = indexOf === baseIndexOf,
4865           seen = getArray();
4866
4867       while (++argsIndex < argsLength) {
4868         var value = arguments[argsIndex];
4869         if (isArray(value) || isArguments(value)) {
4870           args.push(value);
4871           caches.push(trustIndexOf && value.length >= largeArraySize &&
4872             createCache(argsIndex ? args[argsIndex] : seen));
4873         }
4874       }
4875       var array = args[0],
4876           index = -1,
4877           length = array ? array.length : 0,
4878           result = [];
4879
4880       outer:
4881       while (++index < length) {
4882         var cache = caches[0];
4883         value = array[index];
4884
4885         if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) {
4886           argsIndex = argsLength;
4887           (cache || seen).push(value);
4888           while (--argsIndex) {
4889             cache = caches[argsIndex];
4890             if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
4891               continue outer;
4892             }
4893           }
4894           result.push(value);
4895         }
4896       }
4897       while (argsLength--) {
4898         cache = caches[argsLength];
4899         if (cache) {
4900           releaseObject(cache);
4901         }
4902       }
4903       releaseArray(caches);
4904       releaseArray(seen);
4905       return result;
4906     }
4907
4908     /**
4909      * Gets the last element or last `n` elements of an array. If a callback is
4910      * provided elements at the end of the array are returned as long as the
4911      * callback returns truey. The callback is bound to `thisArg` and invoked
4912      * with three arguments; (value, index, array).
4913      *
4914      * If a property name is provided for `callback` the created "_.pluck" style
4915      * callback will return the property value of the given element.
4916      *
4917      * If an object is provided for `callback` the created "_.where" style callback
4918      * will return `true` for elements that have the properties of the given object,
4919      * else `false`.
4920      *
4921      * @static
4922      * @memberOf _
4923      * @category Arrays
4924      * @param {Array} array The array to query.
4925      * @param {Function|Object|number|string} [callback] The function called
4926      *  per element or the number of elements to return. If a property name or
4927      *  object is provided it will be used to create a "_.pluck" or "_.where"
4928      *  style callback, respectively.
4929      * @param {*} [thisArg] The `this` binding of `callback`.
4930      * @returns {*} Returns the last element(s) of `array`.
4931      * @example
4932      *
4933      * _.last([1, 2, 3]);
4934      * // => 3
4935      *
4936      * _.last([1, 2, 3], 2);
4937      * // => [2, 3]
4938      *
4939      * _.last([1, 2, 3], function(num) {
4940      *   return num > 1;
4941      * });
4942      * // => [2, 3]
4943      *
4944      * var characters = [
4945      *   { 'name': 'barney',  'blocked': false, 'employer': 'slate' },
4946      *   { 'name': 'fred',    'blocked': true,  'employer': 'slate' },
4947      *   { 'name': 'pebbles', 'blocked': true,  'employer': 'na' }
4948      * ];
4949      *
4950      * // using "_.pluck" callback shorthand
4951      * _.pluck(_.last(characters, 'blocked'), 'name');
4952      * // => ['fred', 'pebbles']
4953      *
4954      * // using "_.where" callback shorthand
4955      * _.last(characters, { 'employer': 'na' });
4956      * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
4957      */
4958     function last(array, callback, thisArg) {
4959       var n = 0,
4960           length = array ? array.length : 0;
4961
4962       if (typeof callback != 'number' && callback != null) {
4963         var index = length;
4964         callback = lodash.createCallback(callback, thisArg, 3);
4965         while (index-- && callback(array[index], index, array)) {
4966           n++;
4967         }
4968       } else {
4969         n = callback;
4970         if (n == null || thisArg) {
4971           return array ? array[length - 1] : undefined;
4972         }
4973       }
4974       return slice(array, nativeMax(0, length - n));
4975     }
4976
4977     /**
4978      * Gets the index at which the last occurrence of `value` is found using strict
4979      * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
4980      * as the offset from the end of the collection.
4981      *
4982      * If a property name is provided for `callback` the created "_.pluck" style
4983      * callback will return the property value of the given element.
4984      *
4985      * If an object is provided for `callback` the created "_.where" style callback
4986      * will return `true` for elements that have the properties of the given object,
4987      * else `false`.
4988      *
4989      * @static
4990      * @memberOf _
4991      * @category Arrays
4992      * @param {Array} array The array to search.
4993      * @param {*} value The value to search for.
4994      * @param {number} [fromIndex=array.length-1] The index to search from.
4995      * @returns {number} Returns the index of the matched value or `-1`.
4996      * @example
4997      *
4998      * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
4999      * // => 4
5000      *
5001      * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
5002      * // => 1
5003      */
5004     function lastIndexOf(array, value, fromIndex) {
5005       var index = array ? array.length : 0;
5006       if (typeof fromIndex == 'number') {
5007         index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1;
5008       }
5009       while (index--) {
5010         if (array[index] === value) {
5011           return index;
5012         }
5013       }
5014       return -1;
5015     }
5016
5017     /**
5018      * Removes all provided values from the given array using strict equality for
5019      * comparisons, i.e. `===`.
5020      *
5021      * @static
5022      * @memberOf _
5023      * @category Arrays
5024      * @param {Array} array The array to modify.
5025      * @param {...*} [value] The values to remove.
5026      * @returns {Array} Returns `array`.
5027      * @example
5028      *
5029      * var array = [1, 2, 3, 1, 2, 3];
5030      * _.pull(array, 2, 3);
5031      * console.log(array);
5032      * // => [1, 1]
5033      */
5034     function pull(array) {
5035       var args = arguments,
5036           argsIndex = 0,
5037           argsLength = args.length,
5038           length = array ? array.length : 0;
5039
5040       while (++argsIndex < argsLength) {
5041         var index = -1,
5042             value = args[argsIndex];
5043         while (++index < length) {
5044           if (array[index] === value) {
5045             splice.call(array, index--, 1);
5046             length--;
5047           }
5048         }
5049       }
5050       return array;
5051     }
5052
5053     /**
5054      * Creates an array of numbers (positive and/or negative) progressing from
5055      * `start` up to but not including `end`. If `start` is less than `stop` a
5056      * zero-length range is created unless a negative `step` is specified.
5057      *
5058      * @static
5059      * @memberOf _
5060      * @category Arrays
5061      * @param {number} [start=0] The start of the range.
5062      * @param {number} end The end of the range.
5063      * @param {number} [step=1] The value to increment or decrement by.
5064      * @returns {Array} Returns a new range array.
5065      * @example
5066      *
5067      * _.range(4);
5068      * // => [0, 1, 2, 3]
5069      *
5070      * _.range(1, 5);
5071      * // => [1, 2, 3, 4]
5072      *
5073      * _.range(0, 20, 5);
5074      * // => [0, 5, 10, 15]
5075      *
5076      * _.range(0, -4, -1);
5077      * // => [0, -1, -2, -3]
5078      *
5079      * _.range(1, 4, 0);
5080      * // => [1, 1, 1]
5081      *
5082      * _.range(0);
5083      * // => []
5084      */
5085     function range(start, end, step) {
5086       start = +start || 0;
5087       step = typeof step == 'number' ? step : (+step || 1);
5088
5089       if (end == null) {
5090         end = start;
5091         start = 0;
5092       }
5093       // use `Array(length)` so engines like Chakra and V8 avoid slower modes
5094       // http://youtu.be/XAqIpGU8ZZk#t=17m25s
5095       var index = -1,
5096           length = nativeMax(0, ceil((end - start) / (step || 1))),
5097           result = Array(length);
5098
5099       while (++index < length) {
5100         result[index] = start;
5101         start += step;
5102       }
5103       return result;
5104     }
5105
5106     /**
5107      * Removes all elements from an array that the callback returns truey for
5108      * and returns an array of removed elements. The callback is bound to `thisArg`
5109      * and invoked with three arguments; (value, index, array).
5110      *
5111      * If a property name is provided for `callback` the created "_.pluck" style
5112      * callback will return the property value of the given element.
5113      *
5114      * If an object is provided for `callback` the created "_.where" style callback
5115      * will return `true` for elements that have the properties of the given object,
5116      * else `false`.
5117      *
5118      * @static
5119      * @memberOf _
5120      * @category Arrays
5121      * @param {Array} array The array to modify.
5122      * @param {Function|Object|string} [callback=identity] The function called
5123      *  per iteration. If a property name or object is provided it will be used
5124      *  to create a "_.pluck" or "_.where" style callback, respectively.
5125      * @param {*} [thisArg] The `this` binding of `callback`.
5126      * @returns {Array} Returns a new array of removed elements.
5127      * @example
5128      *
5129      * var array = [1, 2, 3, 4, 5, 6];
5130      * var evens = _.remove(array, function(num) { return num % 2 == 0; });
5131      *
5132      * console.log(array);
5133      * // => [1, 3, 5]
5134      *
5135      * console.log(evens);
5136      * // => [2, 4, 6]
5137      */
5138     function remove(array, callback, thisArg) {
5139       var index = -1,
5140           length = array ? array.length : 0,
5141           result = [];
5142
5143       callback = lodash.createCallback(callback, thisArg, 3);
5144       while (++index < length) {
5145         var value = array[index];
5146         if (callback(value, index, array)) {
5147           result.push(value);
5148           splice.call(array, index--, 1);
5149           length--;
5150         }
5151       }
5152       return result;
5153     }
5154
5155     /**
5156      * The opposite of `_.initial` this method gets all but the first element or
5157      * first `n` elements of an array. If a callback function is provided elements
5158      * at the beginning of the array are excluded from the result as long as the
5159      * callback returns truey. The callback is bound to `thisArg` and invoked
5160      * with three arguments; (value, index, array).
5161      *
5162      * If a property name is provided for `callback` the created "_.pluck" style
5163      * callback will return the property value of the given element.
5164      *
5165      * If an object is provided for `callback` the created "_.where" style callback
5166      * will return `true` for elements that have the properties of the given object,
5167      * else `false`.
5168      *
5169      * @static
5170      * @memberOf _
5171      * @alias drop, tail
5172      * @category Arrays
5173      * @param {Array} array The array to query.
5174      * @param {Function|Object|number|string} [callback=1] The function called
5175      *  per element or the number of elements to exclude. If a property name or
5176      *  object is provided it will be used to create a "_.pluck" or "_.where"
5177      *  style callback, respectively.
5178      * @param {*} [thisArg] The `this` binding of `callback`.
5179      * @returns {Array} Returns a slice of `array`.
5180      * @example
5181      *
5182      * _.rest([1, 2, 3]);
5183      * // => [2, 3]
5184      *
5185      * _.rest([1, 2, 3], 2);
5186      * // => [3]
5187      *
5188      * _.rest([1, 2, 3], function(num) {
5189      *   return num < 3;
5190      * });
5191      * // => [3]
5192      *
5193      * var characters = [
5194      *   { 'name': 'barney',  'blocked': true,  'employer': 'slate' },
5195      *   { 'name': 'fred',    'blocked': false,  'employer': 'slate' },
5196      *   { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
5197      * ];
5198      *
5199      * // using "_.pluck" callback shorthand
5200      * _.pluck(_.rest(characters, 'blocked'), 'name');
5201      * // => ['fred', 'pebbles']
5202      *
5203      * // using "_.where" callback shorthand
5204      * _.rest(characters, { 'employer': 'slate' });
5205      * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
5206      */
5207     function rest(array, callback, thisArg) {
5208       if (typeof callback != 'number' && callback != null) {
5209         var n = 0,
5210             index = -1,
5211             length = array ? array.length : 0;
5212
5213         callback = lodash.createCallback(callback, thisArg, 3);
5214         while (++index < length && callback(array[index], index, array)) {
5215           n++;
5216         }
5217       } else {
5218         n = (callback == null || thisArg) ? 1 : nativeMax(0, callback);
5219       }
5220       return slice(array, n);
5221     }
5222
5223     /**
5224      * Uses a binary search to determine the smallest index at which a value
5225      * should be inserted into a given sorted array in order to maintain the sort
5226      * order of the array. If a callback is provided it will be executed for
5227      * `value` and each element of `array` to compute their sort ranking. The
5228      * callback is bound to `thisArg` and invoked with one argument; (value).
5229      *
5230      * If a property name is provided for `callback` the created "_.pluck" style
5231      * callback will return the property value of the given element.
5232      *
5233      * If an object is provided for `callback` the created "_.where" style callback
5234      * will return `true` for elements that have the properties of the given object,
5235      * else `false`.
5236      *
5237      * @static
5238      * @memberOf _
5239      * @category Arrays
5240      * @param {Array} array The array to inspect.
5241      * @param {*} value The value to evaluate.
5242      * @param {Function|Object|string} [callback=identity] The function called
5243      *  per iteration. If a property name or object is provided it will be used
5244      *  to create a "_.pluck" or "_.where" style callback, respectively.
5245      * @param {*} [thisArg] The `this` binding of `callback`.
5246      * @returns {number} Returns the index at which `value` should be inserted
5247      *  into `array`.
5248      * @example
5249      *
5250      * _.sortedIndex([20, 30, 50], 40);
5251      * // => 2
5252      *
5253      * // using "_.pluck" callback shorthand
5254      * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
5255      * // => 2
5256      *
5257      * var dict = {
5258      *   'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
5259      * };
5260      *
5261      * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
5262      *   return dict.wordToNumber[word];
5263      * });
5264      * // => 2
5265      *
5266      * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
5267      *   return this.wordToNumber[word];
5268      * }, dict);
5269      * // => 2
5270      */
5271     function sortedIndex(array, value, callback, thisArg) {
5272       var low = 0,
5273           high = array ? array.length : low;
5274
5275       // explicitly reference `identity` for better inlining in Firefox
5276       callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity;
5277       value = callback(value);
5278
5279       while (low < high) {
5280         var mid = (low + high) >>> 1;
5281         (callback(array[mid]) < value)
5282           ? low = mid + 1
5283           : high = mid;
5284       }
5285       return low;
5286     }
5287
5288     /**
5289      * Creates an array of unique values, in order, of the provided arrays using
5290      * strict equality for comparisons, i.e. `===`.
5291      *
5292      * @static
5293      * @memberOf _
5294      * @category Arrays
5295      * @param {...Array} [array] The arrays to inspect.
5296      * @returns {Array} Returns an array of combined values.
5297      * @example
5298      *
5299      * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
5300      * // => [1, 2, 3, 5, 4]
5301      */
5302     function union() {
5303       return baseUniq(baseFlatten(arguments, true, true));
5304     }
5305
5306     /**
5307      * Creates a duplicate-value-free version of an array using strict equality
5308      * for comparisons, i.e. `===`. If the array is sorted, providing
5309      * `true` for `isSorted` will use a faster algorithm. If a callback is provided
5310      * each element of `array` is passed through the callback before uniqueness
5311      * is computed. The callback is bound to `thisArg` and invoked with three
5312      * arguments; (value, index, array).
5313      *
5314      * If a property name is provided for `callback` the created "_.pluck" style
5315      * callback will return the property value of the given element.
5316      *
5317      * If an object is provided for `callback` the created "_.where" style callback
5318      * will return `true` for elements that have the properties of the given object,
5319      * else `false`.
5320      *
5321      * @static
5322      * @memberOf _
5323      * @alias unique
5324      * @category Arrays
5325      * @param {Array} array The array to process.
5326      * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted.
5327      * @param {Function|Object|string} [callback=identity] The function called
5328      *  per iteration. If a property name or object is provided it will be used
5329      *  to create a "_.pluck" or "_.where" style callback, respectively.
5330      * @param {*} [thisArg] The `this` binding of `callback`.
5331      * @returns {Array} Returns a duplicate-value-free array.
5332      * @example
5333      *
5334      * _.uniq([1, 2, 1, 3, 1]);
5335      * // => [1, 2, 3]
5336      *
5337      * _.uniq([1, 1, 2, 2, 3], true);
5338      * // => [1, 2, 3]
5339      *
5340      * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); });
5341      * // => ['A', 'b', 'C']
5342      *
5343      * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math);
5344      * // => [1, 2.5, 3]
5345      *
5346      * // using "_.pluck" callback shorthand
5347      * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
5348      * // => [{ 'x': 1 }, { 'x': 2 }]
5349      */
5350     function uniq(array, isSorted, callback, thisArg) {
5351       // juggle arguments
5352       if (typeof isSorted != 'boolean' && isSorted != null) {
5353         thisArg = callback;
5354         callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted;
5355         isSorted = false;
5356       }
5357       if (callback != null) {
5358         callback = lodash.createCallback(callback, thisArg, 3);
5359       }
5360       return baseUniq(array, isSorted, callback);
5361     }
5362
5363     /**
5364      * Creates an array excluding all provided values using strict equality for
5365      * comparisons, i.e. `===`.
5366      *
5367      * @static
5368      * @memberOf _
5369      * @category Arrays
5370      * @param {Array} array The array to filter.
5371      * @param {...*} [value] The values to exclude.
5372      * @returns {Array} Returns a new array of filtered values.
5373      * @example
5374      *
5375      * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
5376      * // => [2, 3, 4]
5377      */
5378     function without(array) {
5379       return baseDifference(array, slice(arguments, 1));
5380     }
5381
5382     /**
5383      * Creates an array that is the symmetric difference of the provided arrays.
5384      * See http://en.wikipedia.org/wiki/Symmetric_difference.
5385      *
5386      * @static
5387      * @memberOf _
5388      * @category Arrays
5389      * @param {...Array} [array] The arrays to inspect.
5390      * @returns {Array} Returns an array of values.
5391      * @example
5392      *
5393      * _.xor([1, 2, 3], [5, 2, 1, 4]);
5394      * // => [3, 5, 4]
5395      *
5396      * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
5397      * // => [1, 4, 5]
5398      */
5399     function xor() {
5400       var index = -1,
5401           length = arguments.length;
5402
5403       while (++index < length) {
5404         var array = arguments[index];
5405         if (isArray(array) || isArguments(array)) {
5406           var result = result
5407             ? baseUniq(baseDifference(result, array).concat(baseDifference(array, result)))
5408             : array;
5409         }
5410       }
5411       return result || [];
5412     }
5413
5414     /**
5415      * Creates an array of grouped elements, the first of which contains the first
5416      * elements of the given arrays, the second of which contains the second
5417      * elements of the given arrays, and so on.
5418      *
5419      * @static
5420      * @memberOf _
5421      * @alias unzip
5422      * @category Arrays
5423      * @param {...Array} [array] Arrays to process.
5424      * @returns {Array} Returns a new array of grouped elements.
5425      * @example
5426      *
5427      * _.zip(['fred', 'barney'], [30, 40], [true, false]);
5428      * // => [['fred', 30, true], ['barney', 40, false]]
5429      */
5430     function zip() {
5431       var array = arguments.length > 1 ? arguments : arguments[0],
5432           index = -1,
5433           length = array ? max(pluck(array, 'length')) : 0,
5434           result = Array(length < 0 ? 0 : length);
5435
5436       while (++index < length) {
5437         result[index] = pluck(array, index);
5438       }
5439       return result;
5440     }
5441
5442     /**
5443      * Creates an object composed from arrays of `keys` and `values`. Provide
5444      * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`
5445      * or two arrays, one of `keys` and one of corresponding `values`.
5446      *
5447      * @static
5448      * @memberOf _
5449      * @alias object
5450      * @category Arrays
5451      * @param {Array} keys The array of keys.
5452      * @param {Array} [values=[]] The array of values.
5453      * @returns {Object} Returns an object composed of the given keys and
5454      *  corresponding values.
5455      * @example
5456      *
5457      * _.zipObject(['fred', 'barney'], [30, 40]);
5458      * // => { 'fred': 30, 'barney': 40 }
5459      */
5460     function zipObject(keys, values) {
5461       var index = -1,
5462           length = keys ? keys.length : 0,
5463           result = {};
5464
5465       if (!values && length && !isArray(keys[0])) {
5466         values = [];
5467       }
5468       while (++index < length) {
5469         var key = keys[index];
5470         if (values) {
5471           result[key] = values[index];
5472         } else if (key) {
5473           result[key[0]] = key[1];
5474         }
5475       }
5476       return result;
5477     }
5478
5479     /*--------------------------------------------------------------------------*/
5480
5481     /**
5482      * Creates a function that executes `func`, with  the `this` binding and
5483      * arguments of the created function, only after being called `n` times.
5484      *
5485      * @static
5486      * @memberOf _
5487      * @category Functions
5488      * @param {number} n The number of times the function must be called before
5489      *  `func` is executed.
5490      * @param {Function} func The function to restrict.
5491      * @returns {Function} Returns the new restricted function.
5492      * @example
5493      *
5494      * var saves = ['profile', 'settings'];
5495      *
5496      * var done = _.after(saves.length, function() {
5497      *   console.log('Done saving!');
5498      * });
5499      *
5500      * _.forEach(saves, function(type) {
5501      *   asyncSave({ 'type': type, 'complete': done });
5502      * });
5503      * // => logs 'Done saving!', after all saves have completed
5504      */
5505     function after(n, func) {
5506       if (!isFunction(func)) {
5507         throw new TypeError;
5508       }
5509       return function() {
5510         if (--n < 1) {
5511           return func.apply(this, arguments);
5512         }
5513       };
5514     }
5515
5516     /**
5517      * Creates a function that, when called, invokes `func` with the `this`
5518      * binding of `thisArg` and prepends any additional `bind` arguments to those
5519      * provided to the bound function.
5520      *
5521      * @static
5522      * @memberOf _
5523      * @category Functions
5524      * @param {Function} func The function to bind.
5525      * @param {*} [thisArg] The `this` binding of `func`.
5526      * @param {...*} [arg] Arguments to be partially applied.
5527      * @returns {Function} Returns the new bound function.
5528      * @example
5529      *
5530      * var func = function(greeting) {
5531      *   return greeting + ' ' + this.name;
5532      * };
5533      *
5534      * func = _.bind(func, { 'name': 'fred' }, 'hi');
5535      * func();
5536      * // => 'hi fred'
5537      */
5538     function bind(func, thisArg) {
5539       return arguments.length > 2
5540         ? createWrapper(func, 17, slice(arguments, 2), null, thisArg)
5541         : createWrapper(func, 1, null, null, thisArg);
5542     }
5543
5544     /**
5545      * Binds methods of an object to the object itself, overwriting the existing
5546      * method. Method names may be specified as individual arguments or as arrays
5547      * of method names. If no method names are provided all the function properties
5548      * of `object` will be bound.
5549      *
5550      * @static
5551      * @memberOf _
5552      * @category Functions
5553      * @param {Object} object The object to bind and assign the bound methods to.
5554      * @param {...string} [methodName] The object method names to
5555      *  bind, specified as individual method names or arrays of method names.
5556      * @returns {Object} Returns `object`.
5557      * @example
5558      *
5559      * var view = {
5560      *   'label': 'docs',
5561      *   'onClick': function() { console.log('clicked ' + this.label); }
5562      * };
5563      *
5564      * _.bindAll(view);
5565      * jQuery('#docs').on('click', view.onClick);
5566      * // => logs 'clicked docs', when the button is clicked
5567      */
5568     function bindAll(object) {
5569       var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object),
5570           index = -1,
5571           length = funcs.length;
5572
5573       while (++index < length) {
5574         var key = funcs[index];
5575         object[key] = createWrapper(object[key], 1, null, null, object);
5576       }
5577       return object;
5578     }
5579
5580     /**
5581      * Creates a function that, when called, invokes the method at `object[key]`
5582      * and prepends any additional `bindKey` arguments to those provided to the bound
5583      * function. This method differs from `_.bind` by allowing bound functions to
5584      * reference methods that will be redefined or don't yet exist.
5585      * See http://michaux.ca/articles/lazy-function-definition-pattern.
5586      *
5587      * @static
5588      * @memberOf _
5589      * @category Functions
5590      * @param {Object} object The object the method belongs to.
5591      * @param {string} key The key of the method.
5592      * @param {...*} [arg] Arguments to be partially applied.
5593      * @returns {Function} Returns the new bound function.
5594      * @example
5595      *
5596      * var object = {
5597      *   'name': 'fred',
5598      *   'greet': function(greeting) {
5599      *     return greeting + ' ' + this.name;
5600      *   }
5601      * };
5602      *
5603      * var func = _.bindKey(object, 'greet', 'hi');
5604      * func();
5605      * // => 'hi fred'
5606      *
5607      * object.greet = function(greeting) {
5608      *   return greeting + 'ya ' + this.name + '!';
5609      * };
5610      *
5611      * func();
5612      * // => 'hiya fred!'
5613      */
5614     function bindKey(object, key) {
5615       return arguments.length > 2
5616         ? createWrapper(key, 19, slice(arguments, 2), null, object)
5617         : createWrapper(key, 3, null, null, object);
5618     }
5619
5620     /**
5621      * Creates a function that is the composition of the provided functions,
5622      * where each function consumes the return value of the function that follows.
5623      * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
5624      * Each function is executed with the `this` binding of the composed function.
5625      *
5626      * @static
5627      * @memberOf _
5628      * @category Functions
5629      * @param {...Function} [func] Functions to compose.
5630      * @returns {Function} Returns the new composed function.
5631      * @example
5632      *
5633      * var realNameMap = {
5634      *   'pebbles': 'penelope'
5635      * };
5636      *
5637      * var format = function(name) {
5638      *   name = realNameMap[name.toLowerCase()] || name;
5639      *   return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
5640      * };
5641      *
5642      * var greet = function(formatted) {
5643      *   return 'Hiya ' + formatted + '!';
5644      * };
5645      *
5646      * var welcome = _.compose(greet, format);
5647      * welcome('pebbles');
5648      * // => 'Hiya Penelope!'
5649      */
5650     function compose() {
5651       var funcs = arguments,
5652           length = funcs.length;
5653
5654       while (length--) {
5655         if (!isFunction(funcs[length])) {
5656           throw new TypeError;
5657         }
5658       }
5659       return function() {
5660         var args = arguments,
5661             length = funcs.length;
5662
5663         while (length--) {
5664           args = [funcs[length].apply(this, args)];
5665         }
5666         return args[0];
5667       };
5668     }
5669
5670     /**
5671      * Creates a function which accepts one or more arguments of `func` that when
5672      * invoked either executes `func` returning its result, if all `func` arguments
5673      * have been provided, or returns a function that accepts one or more of the
5674      * remaining `func` arguments, and so on. The arity of `func` can be specified
5675      * if `func.length` is not sufficient.
5676      *
5677      * @static
5678      * @memberOf _
5679      * @category Functions
5680      * @param {Function} func The function to curry.
5681      * @param {number} [arity=func.length] The arity of `func`.
5682      * @returns {Function} Returns the new curried function.
5683      * @example
5684      *
5685      * var curried = _.curry(function(a, b, c) {
5686      *   console.log(a + b + c);
5687      * });
5688      *
5689      * curried(1)(2)(3);
5690      * // => 6
5691      *
5692      * curried(1, 2)(3);
5693      * // => 6
5694      *
5695      * curried(1, 2, 3);
5696      * // => 6
5697      */
5698     function curry(func, arity) {
5699       arity = typeof arity == 'number' ? arity : (+arity || func.length);
5700       return createWrapper(func, 4, null, null, null, arity);
5701     }
5702
5703     /**
5704      * Creates a function that will delay the execution of `func` until after
5705      * `wait` milliseconds have elapsed since the last time it was invoked.
5706      * Provide an options object to indicate that `func` should be invoked on
5707      * the leading and/or trailing edge of the `wait` timeout. Subsequent calls
5708      * to the debounced function will return the result of the last `func` call.
5709      *
5710      * Note: If `leading` and `trailing` options are `true` `func` will be called
5711      * on the trailing edge of the timeout only if the the debounced function is
5712      * invoked more than once during the `wait` timeout.
5713      *
5714      * @static
5715      * @memberOf _
5716      * @category Functions
5717      * @param {Function} func The function to debounce.
5718      * @param {number} wait The number of milliseconds to delay.
5719      * @param {Object} [options] The options object.
5720      * @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout.
5721      * @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called.
5722      * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
5723      * @returns {Function} Returns the new debounced function.
5724      * @example
5725      *
5726      * // avoid costly calculations while the window size is in flux
5727      * var lazyLayout = _.debounce(calculateLayout, 150);
5728      * jQuery(window).on('resize', lazyLayout);
5729      *
5730      * // execute `sendMail` when the click event is fired, debouncing subsequent calls
5731      * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
5732      *   'leading': true,
5733      *   'trailing': false
5734      * });
5735      *
5736      * // ensure `batchLog` is executed once after 1 second of debounced calls
5737      * var source = new EventSource('/stream');
5738      * source.addEventListener('message', _.debounce(batchLog, 250, {
5739      *   'maxWait': 1000
5740      * }, false);
5741      */
5742     function debounce(func, wait, options) {
5743       var args,
5744           maxTimeoutId,
5745           result,
5746           stamp,
5747           thisArg,
5748           timeoutId,
5749           trailingCall,
5750           lastCalled = 0,
5751           maxWait = false,
5752           trailing = true;
5753
5754       if (!isFunction(func)) {
5755         throw new TypeError;
5756       }
5757       wait = nativeMax(0, wait) || 0;
5758       if (options === true) {
5759         var leading = true;
5760         trailing = false;
5761       } else if (isObject(options)) {
5762         leading = options.leading;
5763         maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0);
5764         trailing = 'trailing' in options ? options.trailing : trailing;
5765       }
5766       var delayed = function() {
5767         var remaining = wait - (now() - stamp);
5768         if (remaining <= 0) {
5769           if (maxTimeoutId) {
5770             clearTimeout(maxTimeoutId);
5771           }
5772           var isCalled = trailingCall;
5773           maxTimeoutId = timeoutId = trailingCall = undefined;
5774           if (isCalled) {
5775             lastCalled = now();
5776             result = func.apply(thisArg, args);
5777             if (!timeoutId && !maxTimeoutId) {
5778               args = thisArg = null;
5779             }
5780           }
5781         } else {
5782           timeoutId = setTimeout(delayed, remaining);
5783         }
5784       };
5785
5786       var maxDelayed = function() {
5787         if (timeoutId) {
5788           clearTimeout(timeoutId);
5789         }
5790         maxTimeoutId = timeoutId = trailingCall = undefined;
5791         if (trailing || (maxWait !== wait)) {
5792           lastCalled = now();
5793           result = func.apply(thisArg, args);
5794           if (!timeoutId && !maxTimeoutId) {
5795             args = thisArg = null;
5796           }
5797         }
5798       };
5799
5800       return function() {
5801         args = arguments;
5802         stamp = now();
5803         thisArg = this;
5804         trailingCall = trailing && (timeoutId || !leading);
5805
5806         if (maxWait === false) {
5807           var leadingCall = leading && !timeoutId;
5808         } else {
5809           if (!maxTimeoutId && !leading) {
5810             lastCalled = stamp;
5811           }
5812           var remaining = maxWait - (stamp - lastCalled),
5813               isCalled = remaining <= 0;
5814
5815           if (isCalled) {
5816             if (maxTimeoutId) {
5817               maxTimeoutId = clearTimeout(maxTimeoutId);
5818             }
5819             lastCalled = stamp;
5820             result = func.apply(thisArg, args);
5821           }
5822           else if (!maxTimeoutId) {
5823             maxTimeoutId = setTimeout(maxDelayed, remaining);
5824           }
5825         }
5826         if (isCalled && timeoutId) {
5827           timeoutId = clearTimeout(timeoutId);
5828         }
5829         else if (!timeoutId && wait !== maxWait) {
5830           timeoutId = setTimeout(delayed, wait);
5831         }
5832         if (leadingCall) {
5833           isCalled = true;
5834           result = func.apply(thisArg, args);
5835         }
5836         if (isCalled && !timeoutId && !maxTimeoutId) {
5837           args = thisArg = null;
5838         }
5839         return result;
5840       };
5841     }
5842
5843     /**
5844      * Defers executing the `func` function until the current call stack has cleared.
5845      * Additional arguments will be provided to `func` when it is invoked.
5846      *
5847      * @static
5848      * @memberOf _
5849      * @category Functions
5850      * @param {Function} func The function to defer.
5851      * @param {...*} [arg] Arguments to invoke the function with.
5852      * @returns {number} Returns the timer id.
5853      * @example
5854      *
5855      * _.defer(function(text) { console.log(text); }, 'deferred');
5856      * // logs 'deferred' after one or more milliseconds
5857      */
5858     function defer(func) {
5859       if (!isFunction(func)) {
5860         throw new TypeError;
5861       }
5862       var args = slice(arguments, 1);
5863       return setTimeout(function() { func.apply(undefined, args); }, 1);
5864     }
5865
5866     /**
5867      * Executes the `func` function after `wait` milliseconds. Additional arguments
5868      * will be provided to `func` when it is invoked.
5869      *
5870      * @static
5871      * @memberOf _
5872      * @category Functions
5873      * @param {Function} func The function to delay.
5874      * @param {number} wait The number of milliseconds to delay execution.
5875      * @param {...*} [arg] Arguments to invoke the function with.
5876      * @returns {number} Returns the timer id.
5877      * @example
5878      *
5879      * _.delay(function(text) { console.log(text); }, 1000, 'later');
5880      * // => logs 'later' after one second
5881      */
5882     function delay(func, wait) {
5883       if (!isFunction(func)) {
5884         throw new TypeError;
5885       }
5886       var args = slice(arguments, 2);
5887       return setTimeout(function() { func.apply(undefined, args); }, wait);
5888     }
5889
5890     /**
5891      * Creates a function that memoizes the result of `func`. If `resolver` is
5892      * provided it will be used to determine the cache key for storing the result
5893      * based on the arguments provided to the memoized function. By default, the
5894      * first argument provided to the memoized function is used as the cache key.
5895      * The `func` is executed with the `this` binding of the memoized function.
5896      * The result cache is exposed as the `cache` property on the memoized function.
5897      *
5898      * @static
5899      * @memberOf _
5900      * @category Functions
5901      * @param {Function} func The function to have its output memoized.
5902      * @param {Function} [resolver] A function used to resolve the cache key.
5903      * @returns {Function} Returns the new memoizing function.
5904      * @example
5905      *
5906      * var fibonacci = _.memoize(function(n) {
5907      *   return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
5908      * });
5909      *
5910      * fibonacci(9)
5911      * // => 34
5912      *
5913      * var data = {
5914      *   'fred': { 'name': 'fred', 'age': 40 },
5915      *   'pebbles': { 'name': 'pebbles', 'age': 1 }
5916      * };
5917      *
5918      * // modifying the result cache
5919      * var get = _.memoize(function(name) { return data[name]; }, _.identity);
5920      * get('pebbles');
5921      * // => { 'name': 'pebbles', 'age': 1 }
5922      *
5923      * get.cache.pebbles.name = 'penelope';
5924      * get('pebbles');
5925      * // => { 'name': 'penelope', 'age': 1 }
5926      */
5927     function memoize(func, resolver) {
5928       if (!isFunction(func)) {
5929         throw new TypeError;
5930       }
5931       var memoized = function() {
5932         var cache = memoized.cache,
5933             key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0];
5934
5935         return hasOwnProperty.call(cache, key)
5936           ? cache[key]
5937           : (cache[key] = func.apply(this, arguments));
5938       }
5939       memoized.cache = {};
5940       return memoized;
5941     }
5942
5943     /**
5944      * Creates a function that is restricted to execute `func` once. Repeat calls to
5945      * the function will return the value of the first call. The `func` is executed
5946      * with the `this` binding of the created function.
5947      *
5948      * @static
5949      * @memberOf _
5950      * @category Functions
5951      * @param {Function} func The function to restrict.
5952      * @returns {Function} Returns the new restricted function.
5953      * @example
5954      *
5955      * var initialize = _.once(createApplication);
5956      * initialize();
5957      * initialize();
5958      * // `initialize` executes `createApplication` once
5959      */
5960     function once(func) {
5961       var ran,
5962           result;
5963
5964       if (!isFunction(func)) {
5965         throw new TypeError;
5966       }
5967       return function() {
5968         if (ran) {
5969           return result;
5970         }
5971         ran = true;
5972         result = func.apply(this, arguments);
5973
5974         // clear the `func` variable so the function may be garbage collected
5975         func = null;
5976         return result;
5977       };
5978     }
5979
5980     /**
5981      * Creates a function that, when called, invokes `func` with any additional
5982      * `partial` arguments prepended to those provided to the new function. This
5983      * method is similar to `_.bind` except it does **not** alter the `this` binding.
5984      *
5985      * @static
5986      * @memberOf _
5987      * @category Functions
5988      * @param {Function} func The function to partially apply arguments to.
5989      * @param {...*} [arg] Arguments to be partially applied.
5990      * @returns {Function} Returns the new partially applied function.
5991      * @example
5992      *
5993      * var greet = function(greeting, name) { return greeting + ' ' + name; };
5994      * var hi = _.partial(greet, 'hi');
5995      * hi('fred');
5996      * // => 'hi fred'
5997      */
5998     function partial(func) {
5999       return createWrapper(func, 16, slice(arguments, 1));
6000     }
6001
6002     /**
6003      * This method is like `_.partial` except that `partial` arguments are
6004      * appended to those provided to the new function.
6005      *
6006      * @static
6007      * @memberOf _
6008      * @category Functions
6009      * @param {Function} func The function to partially apply arguments to.
6010      * @param {...*} [arg] Arguments to be partially applied.
6011      * @returns {Function} Returns the new partially applied function.
6012      * @example
6013      *
6014      * var defaultsDeep = _.partialRight(_.merge, _.defaults);
6015      *
6016      * var options = {
6017      *   'variable': 'data',
6018      *   'imports': { 'jq': $ }
6019      * };
6020      *
6021      * defaultsDeep(options, _.templateSettings);
6022      *
6023      * options.variable
6024      * // => 'data'
6025      *
6026      * options.imports
6027      * // => { '_': _, 'jq': $ }
6028      */
6029     function partialRight(func) {
6030       return createWrapper(func, 32, null, slice(arguments, 1));
6031     }
6032
6033     /**
6034      * Creates a function that, when executed, will only call the `func` function
6035      * at most once per every `wait` milliseconds. Provide an options object to
6036      * indicate that `func` should be invoked on the leading and/or trailing edge
6037      * of the `wait` timeout. Subsequent calls to the throttled function will
6038      * return the result of the last `func` call.
6039      *
6040      * Note: If `leading` and `trailing` options are `true` `func` will be called
6041      * on the trailing edge of the timeout only if the the throttled function is
6042      * invoked more than once during the `wait` timeout.
6043      *
6044      * @static
6045      * @memberOf _
6046      * @category Functions
6047      * @param {Function} func The function to throttle.
6048      * @param {number} wait The number of milliseconds to throttle executions to.
6049      * @param {Object} [options] The options object.
6050      * @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout.
6051      * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
6052      * @returns {Function} Returns the new throttled function.
6053      * @example
6054      *
6055      * // avoid excessively updating the position while scrolling
6056      * var throttled = _.throttle(updatePosition, 100);
6057      * jQuery(window).on('scroll', throttled);
6058      *
6059      * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes
6060      * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
6061      *   'trailing': false
6062      * }));
6063      */
6064     function throttle(func, wait, options) {
6065       var leading = true,
6066           trailing = true;
6067
6068       if (!isFunction(func)) {
6069         throw new TypeError;
6070       }
6071       if (options === false) {
6072         leading = false;
6073       } else if (isObject(options)) {
6074         leading = 'leading' in options ? options.leading : leading;
6075         trailing = 'trailing' in options ? options.trailing : trailing;
6076       }
6077       debounceOptions.leading = leading;
6078       debounceOptions.maxWait = wait;
6079       debounceOptions.trailing = trailing;
6080
6081       return debounce(func, wait, debounceOptions);
6082     }
6083
6084     /**
6085      * Creates a function that provides `value` to the wrapper function as its
6086      * first argument. Additional arguments provided to the function are appended
6087      * to those provided to the wrapper function. The wrapper is executed with
6088      * the `this` binding of the created function.
6089      *
6090      * @static
6091      * @memberOf _
6092      * @category Functions
6093      * @param {*} value The value to wrap.
6094      * @param {Function} wrapper The wrapper function.
6095      * @returns {Function} Returns the new function.
6096      * @example
6097      *
6098      * var p = _.wrap(_.escape, function(func, text) {
6099      *   return '<p>' + func(text) + '</p>';
6100      * });
6101      *
6102      * p('Fred, Wilma, & Pebbles');
6103      * // => '<p>Fred, Wilma, &amp; Pebbles</p>'
6104      */
6105     function wrap(value, wrapper) {
6106       return createWrapper(wrapper, 16, [value]);
6107     }
6108
6109     /*--------------------------------------------------------------------------*/
6110
6111     /**
6112      * Creates a function that returns `value`.
6113      *
6114      * @static
6115      * @memberOf _
6116      * @category Utilities
6117      * @param {*} value The value to return from the new function.
6118      * @returns {Function} Returns the new function.
6119      * @example
6120      *
6121      * var object = { 'name': 'fred' };
6122      * var getter = _.constant(object);
6123      * getter() === object;
6124      * // => true
6125      */
6126     function constant(value) {
6127       return function() {
6128         return value;
6129       };
6130     }
6131
6132     /**
6133      * Produces a callback bound to an optional `thisArg`. If `func` is a property
6134      * name the created callback will return the property value for a given element.
6135      * If `func` is an object the created callback will return `true` for elements
6136      * that contain the equivalent object properties, otherwise it will return `false`.
6137      *
6138      * @static
6139      * @memberOf _
6140      * @category Utilities
6141      * @param {*} [func=identity] The value to convert to a callback.
6142      * @param {*} [thisArg] The `this` binding of the created callback.
6143      * @param {number} [argCount] The number of arguments the callback accepts.
6144      * @returns {Function} Returns a callback function.
6145      * @example
6146      *
6147      * var characters = [
6148      *   { 'name': 'barney', 'age': 36 },
6149      *   { 'name': 'fred',   'age': 40 }
6150      * ];
6151      *
6152      * // wrap to create custom callback shorthands
6153      * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
6154      *   var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
6155      *   return !match ? func(callback, thisArg) : function(object) {
6156      *     return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
6157      *   };
6158      * });
6159      *
6160      * _.filter(characters, 'age__gt38');
6161      * // => [{ 'name': 'fred', 'age': 40 }]
6162      */
6163     function createCallback(func, thisArg, argCount) {
6164       var type = typeof func;
6165       if (func == null || type == 'function') {
6166         return baseCreateCallback(func, thisArg, argCount);
6167       }
6168       // handle "_.pluck" style callback shorthands
6169       if (type != 'object') {
6170         return property(func);
6171       }
6172       var props = keys(func),
6173           key = props[0],
6174           a = func[key];
6175
6176       // handle "_.where" style callback shorthands
6177       if (props.length == 1 && a === a && !isObject(a)) {
6178         // fast path the common case of providing an object with a single
6179         // property containing a primitive value
6180         return function(object) {
6181           var b = object[key];
6182           return a === b && (a !== 0 || (1 / a == 1 / b));
6183         };
6184       }
6185       return function(object) {
6186         var length = props.length,
6187             result = false;
6188
6189         while (length--) {
6190           if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
6191             break;
6192           }
6193         }
6194         return result;
6195       };
6196     }
6197
6198     /**
6199      * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
6200      * corresponding HTML entities.
6201      *
6202      * @static
6203      * @memberOf _
6204      * @category Utilities
6205      * @param {string} string The string to escape.
6206      * @returns {string} Returns the escaped string.
6207      * @example
6208      *
6209      * _.escape('Fred, Wilma, & Pebbles');
6210      * // => 'Fred, Wilma, &amp; Pebbles'
6211      */
6212     function escape(string) {
6213       return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
6214     }
6215
6216     /**
6217      * This method returns the first argument provided to it.
6218      *
6219      * @static
6220      * @memberOf _
6221      * @category Utilities
6222      * @param {*} value Any value.
6223      * @returns {*} Returns `value`.
6224      * @example
6225      *
6226      * var object = { 'name': 'fred' };
6227      * _.identity(object) === object;
6228      * // => true
6229      */
6230     function identity(value) {
6231       return value;
6232     }
6233
6234     /**
6235      * Adds function properties of a source object to the destination object.
6236      * If `object` is a function methods will be added to its prototype as well.
6237      *
6238      * @static
6239      * @memberOf _
6240      * @category Utilities
6241      * @param {Function|Object} [object=lodash] object The destination object.
6242      * @param {Object} source The object of functions to add.
6243      * @param {Object} [options] The options object.
6244      * @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
6245      * @example
6246      *
6247      * function capitalize(string) {
6248      *   return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
6249      * }
6250      *
6251      * _.mixin({ 'capitalize': capitalize });
6252      * _.capitalize('fred');
6253      * // => 'Fred'
6254      *
6255      * _('fred').capitalize().value();
6256      * // => 'Fred'
6257      *
6258      * _.mixin({ 'capitalize': capitalize }, { 'chain': false });
6259      * _('fred').capitalize();
6260      * // => 'Fred'
6261      */
6262     function mixin(object, source, options) {
6263       var chain = true,
6264           methodNames = source && functions(source);
6265
6266       if (!source || (!options && !methodNames.length)) {
6267         if (options == null) {
6268           options = source;
6269         }
6270         ctor = lodashWrapper;
6271         source = object;
6272         object = lodash;
6273         methodNames = functions(source);
6274       }
6275       if (options === false) {
6276         chain = false;
6277       } else if (isObject(options) && 'chain' in options) {
6278         chain = options.chain;
6279       }
6280       var ctor = object,
6281           isFunc = isFunction(ctor);
6282
6283       forEach(methodNames, function(methodName) {
6284         var func = object[methodName] = source[methodName];
6285         if (isFunc) {
6286           ctor.prototype[methodName] = function() {
6287             var chainAll = this.__chain__,
6288                 value = this.__wrapped__,
6289                 args = [value];
6290
6291             push.apply(args, arguments);
6292             var result = func.apply(object, args);
6293             if (chain || chainAll) {
6294               if (value === result && isObject(result)) {
6295                 return this;
6296               }
6297               result = new ctor(result);
6298               result.__chain__ = chainAll;
6299             }
6300             return result;
6301           };
6302         }
6303       });
6304     }
6305
6306     /**
6307      * Reverts the '_' variable to its previous value and returns a reference to
6308      * the `lodash` function.
6309      *
6310      * @static
6311      * @memberOf _
6312      * @category Utilities
6313      * @returns {Function} Returns the `lodash` function.
6314      * @example
6315      *
6316      * var lodash = _.noConflict();
6317      */
6318     function noConflict() {
6319       context._ = oldDash;
6320       return this;
6321     }
6322
6323     /**
6324      * A no-operation function.
6325      *
6326      * @static
6327      * @memberOf _
6328      * @category Utilities
6329      * @example
6330      *
6331      * var object = { 'name': 'fred' };
6332      * _.noop(object) === undefined;
6333      * // => true
6334      */
6335     function noop() {
6336       // no operation performed
6337     }
6338
6339     /**
6340      * Gets the number of milliseconds that have elapsed since the Unix epoch
6341      * (1 January 1970 00:00:00 UTC).
6342      *
6343      * @static
6344      * @memberOf _
6345      * @category Utilities
6346      * @example
6347      *
6348      * var stamp = _.now();
6349      * _.defer(function() { console.log(_.now() - stamp); });
6350      * // => logs the number of milliseconds it took for the deferred function to be called
6351      */
6352     var now = isNative(now = Date.now) && now || function() {
6353       return new Date().getTime();
6354     };
6355
6356     /**
6357      * Converts the given value into an integer of the specified radix.
6358      * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the
6359      * `value` is a hexadecimal, in which case a `radix` of `16` is used.
6360      *
6361      * Note: This method avoids differences in native ES3 and ES5 `parseInt`
6362      * implementations. See http://es5.github.io/#E.
6363      *
6364      * @static
6365      * @memberOf _
6366      * @category Utilities
6367      * @param {string} value The value to parse.
6368      * @param {number} [radix] The radix used to interpret the value to parse.
6369      * @returns {number} Returns the new integer value.
6370      * @example
6371      *
6372      * _.parseInt('08');
6373      * // => 8
6374      */
6375     var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) {
6376       // Firefox < 21 and Opera < 15 follow the ES3 specified implementation of `parseInt`
6377       return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0);
6378     };
6379
6380     /**
6381      * Creates a "_.pluck" style function, which returns the `key` value of a
6382      * given object.
6383      *
6384      * @static
6385      * @memberOf _
6386      * @category Utilities
6387      * @param {string} key The name of the property to retrieve.
6388      * @returns {Function} Returns the new function.
6389      * @example
6390      *
6391      * var characters = [
6392      *   { 'name': 'fred',   'age': 40 },
6393      *   { 'name': 'barney', 'age': 36 }
6394      * ];
6395      *
6396      * var getName = _.property('name');
6397      *
6398      * _.map(characters, getName);
6399      * // => ['barney', 'fred']
6400      *
6401      * _.sortBy(characters, getName);
6402      * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred',   'age': 40 }]
6403      */
6404     function property(key) {
6405       return function(object) {
6406         return object[key];
6407       };
6408     }
6409
6410     /**
6411      * Produces a random number between `min` and `max` (inclusive). If only one
6412      * argument is provided a number between `0` and the given number will be
6413      * returned. If `floating` is truey or either `min` or `max` are floats a
6414      * floating-point number will be returned instead of an integer.
6415      *
6416      * @static
6417      * @memberOf _
6418      * @category Utilities
6419      * @param {number} [min=0] The minimum possible value.
6420      * @param {number} [max=1] The maximum possible value.
6421      * @param {boolean} [floating=false] Specify returning a floating-point number.
6422      * @returns {number} Returns a random number.
6423      * @example
6424      *
6425      * _.random(0, 5);
6426      * // => an integer between 0 and 5
6427      *
6428      * _.random(5);
6429      * // => also an integer between 0 and 5
6430      *
6431      * _.random(5, true);
6432      * // => a floating-point number between 0 and 5
6433      *
6434      * _.random(1.2, 5.2);
6435      * // => a floating-point number between 1.2 and 5.2
6436      */
6437     function random(min, max, floating) {
6438       var noMin = min == null,
6439           noMax = max == null;
6440
6441       if (floating == null) {
6442         if (typeof min == 'boolean' && noMax) {
6443           floating = min;
6444           min = 1;
6445         }
6446         else if (!noMax && typeof max == 'boolean') {
6447           floating = max;
6448           noMax = true;
6449         }
6450       }
6451       if (noMin && noMax) {
6452         max = 1;
6453       }
6454       min = +min || 0;
6455       if (noMax) {
6456         max = min;
6457         min = 0;
6458       } else {
6459         max = +max || 0;
6460       }
6461       if (floating || min % 1 || max % 1) {
6462         var rand = nativeRandom();
6463         return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1)))), max);
6464       }
6465       return baseRandom(min, max);
6466     }
6467
6468     /**
6469      * Resolves the value of property `key` on `object`. If `key` is a function
6470      * it will be invoked with the `this` binding of `object` and its result returned,
6471      * else the property value is returned. If `object` is falsey then `undefined`
6472      * is returned.
6473      *
6474      * @static
6475      * @memberOf _
6476      * @category Utilities
6477      * @param {Object} object The object to inspect.
6478      * @param {string} key The name of the property to resolve.
6479      * @returns {*} Returns the resolved value.
6480      * @example
6481      *
6482      * var object = {
6483      *   'cheese': 'crumpets',
6484      *   'stuff': function() {
6485      *     return 'nonsense';
6486      *   }
6487      * };
6488      *
6489      * _.result(object, 'cheese');
6490      * // => 'crumpets'
6491      *
6492      * _.result(object, 'stuff');
6493      * // => 'nonsense'
6494      */
6495     function result(object, key) {
6496       if (object) {
6497         var value = object[key];
6498         return isFunction(value) ? object[key]() : value;
6499       }
6500     }
6501
6502     /**
6503      * A micro-templating method that handles arbitrary delimiters, preserves
6504      * whitespace, and correctly escapes quotes within interpolated code.
6505      *
6506      * Note: In the development build, `_.template` utilizes sourceURLs for easier
6507      * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
6508      *
6509      * For more information on precompiling templates see:
6510      * https://lodash.com/custom-builds
6511      *
6512      * For more information on Chrome extension sandboxes see:
6513      * http://developer.chrome.com/stable/extensions/sandboxingEval.html
6514      *
6515      * @static
6516      * @memberOf _
6517      * @category Utilities
6518      * @param {string} text The template text.
6519      * @param {Object} data The data object used to populate the text.
6520      * @param {Object} [options] The options object.
6521      * @param {RegExp} [options.escape] The "escape" delimiter.
6522      * @param {RegExp} [options.evaluate] The "evaluate" delimiter.
6523      * @param {Object} [options.imports] An object to import into the template as local variables.
6524      * @param {RegExp} [options.interpolate] The "interpolate" delimiter.
6525      * @param {string} [sourceURL] The sourceURL of the template's compiled source.
6526      * @param {string} [variable] The data object variable name.
6527      * @returns {Function|string} Returns a compiled function when no `data` object
6528      *  is given, else it returns the interpolated text.
6529      * @example
6530      *
6531      * // using the "interpolate" delimiter to create a compiled template
6532      * var compiled = _.template('hello <%= name %>');
6533      * compiled({ 'name': 'fred' });
6534      * // => 'hello fred'
6535      *
6536      * // using the "escape" delimiter to escape HTML in data property values
6537      * _.template('<b><%- value %></b>', { 'value': '<script>' });
6538      * // => '<b>&lt;script&gt;</b>'
6539      *
6540      * // using the "evaluate" delimiter to generate HTML
6541      * var list = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>';
6542      * _.template(list, { 'people': ['fred', 'barney'] });
6543      * // => '<li>fred</li><li>barney</li>'
6544      *
6545      * // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
6546      * _.template('hello ${ name }', { 'name': 'pebbles' });
6547      * // => 'hello pebbles'
6548      *
6549      * // using the internal `print` function in "evaluate" delimiters
6550      * _.template('<% print("hello " + name); %>!', { 'name': 'barney' });
6551      * // => 'hello barney!'
6552      *
6553      * // using a custom template delimiters
6554      * _.templateSettings = {
6555      *   'interpolate': /{{([\s\S]+?)}}/g
6556      * };
6557      *
6558      * _.template('hello {{ name }}!', { 'name': 'mustache' });
6559      * // => 'hello mustache!'
6560      *
6561      * // using the `imports` option to import jQuery
6562      * var list = '<% jq.each(people, function(name) { %><li><%- name %></li><% }); %>';
6563      * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
6564      * // => '<li>fred</li><li>barney</li>'
6565      *
6566      * // using the `sourceURL` option to specify a custom sourceURL for the template
6567      * var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
6568      * compiled(data);
6569      * // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
6570      *
6571      * // using the `variable` option to ensure a with-statement isn't used in the compiled template
6572      * var compiled = _.template('hi <%= data.name %>!', null, { 'variable': 'data' });
6573      * compiled.source;
6574      * // => function(data) {
6575      *   var __t, __p = '', __e = _.escape;
6576      *   __p += 'hi ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
6577      *   return __p;
6578      * }
6579      *
6580      * // using the `source` property to inline compiled templates for meaningful
6581      * // line numbers in error messages and a stack trace
6582      * fs.writeFileSync(path.join(cwd, 'jst.js'), '\
6583      *   var JST = {\
6584      *     "main": ' + _.template(mainText).source + '\
6585      *   };\
6586      * ');
6587      */
6588     function template(text, data, options) {
6589       // based on John Resig's `tmpl` implementation
6590       // http://ejohn.org/blog/javascript-micro-templating/
6591       // and Laura Doktorova's doT.js
6592       // https://github.com/olado/doT
6593       var settings = lodash.templateSettings;
6594       text = String(text || '');
6595
6596       // avoid missing dependencies when `iteratorTemplate` is not defined
6597       options = iteratorTemplate ? defaults({}, options, settings) : settings;
6598
6599       var imports = iteratorTemplate && defaults({}, options.imports, settings.imports),
6600           importsKeys = iteratorTemplate ? keys(imports) : ['_'],
6601           importsValues = iteratorTemplate ? values(imports) : [lodash];
6602
6603       var isEvaluating,
6604           index = 0,
6605           interpolate = options.interpolate || reNoMatch,
6606           source = "__p += '";
6607
6608       // compile the regexp to match each delimiter
6609       var reDelimiters = RegExp(
6610         (options.escape || reNoMatch).source + '|' +
6611         interpolate.source + '|' +
6612         (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
6613         (options.evaluate || reNoMatch).source + '|$'
6614       , 'g');
6615
6616       text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
6617         interpolateValue || (interpolateValue = esTemplateValue);
6618
6619         // escape characters that cannot be included in string literals
6620         source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar);
6621
6622         // replace delimiters with snippets
6623         if (escapeValue) {
6624           source += "' +\n__e(" + escapeValue + ") +\n'";
6625         }
6626         if (evaluateValue) {
6627           isEvaluating = true;
6628           source += "';\n" + evaluateValue + ";\n__p += '";
6629         }
6630         if (interpolateValue) {
6631           source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
6632         }
6633         index = offset + match.length;
6634
6635         // the JS engine embedded in Adobe products requires returning the `match`
6636         // string in order to produce the correct `offset` value
6637         return match;
6638       });
6639
6640       source += "';\n";
6641
6642       // if `variable` is not specified, wrap a with-statement around the generated
6643       // code to add the data object to the top of the scope chain
6644       var variable = options.variable,
6645           hasVariable = variable;
6646
6647       if (!hasVariable) {
6648         variable = 'obj';
6649         source = 'with (' + variable + ') {\n' + source + '\n}\n';
6650       }
6651       // cleanup code by stripping empty strings
6652       source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
6653         .replace(reEmptyStringMiddle, '$1')
6654         .replace(reEmptyStringTrailing, '$1;');
6655
6656       // frame code as the function body
6657       source = 'function(' + variable + ') {\n' +
6658         (hasVariable ? '' : variable + ' || (' + variable + ' = {});\n') +
6659         "var __t, __p = '', __e = _.escape" +
6660         (isEvaluating
6661           ? ', __j = Array.prototype.join;\n' +
6662             "function print() { __p += __j.call(arguments, '') }\n"
6663           : ';\n'
6664         ) +
6665         source +
6666         'return __p\n}';
6667
6668       // Use a sourceURL for easier debugging.
6669       // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
6670       var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';
6671
6672       try {
6673         var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues);
6674       } catch(e) {
6675         e.source = source;
6676         throw e;
6677       }
6678       if (data) {
6679         return result(data);
6680       }
6681       // provide the compiled function's source by its `toString` method, in
6682       // supported environments, or the `source` property as a convenience for
6683       // inlining compiled templates during the build process
6684       result.source = source;
6685       return result;
6686     }
6687
6688     /**
6689      * Executes the callback `n` times, returning an array of the results
6690      * of each callback execution. The callback is bound to `thisArg` and invoked
6691      * with one argument; (index).
6692      *
6693      * @static
6694      * @memberOf _
6695      * @category Utilities
6696      * @param {number} n The number of times to execute the callback.
6697      * @param {Function} callback The function called per iteration.
6698      * @param {*} [thisArg] The `this` binding of `callback`.
6699      * @returns {Array} Returns an array of the results of each `callback` execution.
6700      * @example
6701      *
6702      * var diceRolls = _.times(3, _.partial(_.random, 1, 6));
6703      * // => [3, 6, 4]
6704      *
6705      * _.times(3, function(n) { mage.castSpell(n); });
6706      * // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
6707      *
6708      * _.times(3, function(n) { this.cast(n); }, mage);
6709      * // => also calls `mage.castSpell(n)` three times
6710      */
6711     function times(n, callback, thisArg) {
6712       n = (n = +n) > -1 ? n : 0;
6713       var index = -1,
6714           result = Array(n);
6715
6716       callback = baseCreateCallback(callback, thisArg, 1);
6717       while (++index < n) {
6718         result[index] = callback(index);
6719       }
6720       return result;
6721     }
6722
6723     /**
6724      * The inverse of `_.escape` this method converts the HTML entities
6725      * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their
6726      * corresponding characters.
6727      *
6728      * @static
6729      * @memberOf _
6730      * @category Utilities
6731      * @param {string} string The string to unescape.
6732      * @returns {string} Returns the unescaped string.
6733      * @example
6734      *
6735      * _.unescape('Fred, Barney &amp; Pebbles');
6736      * // => 'Fred, Barney & Pebbles'
6737      */
6738     function unescape(string) {
6739       return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
6740     }
6741
6742     /**
6743      * Generates a unique ID. If `prefix` is provided the ID will be appended to it.
6744      *
6745      * @static
6746      * @memberOf _
6747      * @category Utilities
6748      * @param {string} [prefix] The value to prefix the ID with.
6749      * @returns {string} Returns the unique ID.
6750      * @example
6751      *
6752      * _.uniqueId('contact_');
6753      * // => 'contact_104'
6754      *
6755      * _.uniqueId();
6756      * // => '105'
6757      */
6758     function uniqueId(prefix) {
6759       var id = ++idCounter;
6760       return String(prefix == null ? '' : prefix) + id;
6761     }
6762
6763     /*--------------------------------------------------------------------------*/
6764
6765     /**
6766      * Creates a `lodash` object that wraps the given value with explicit
6767      * method chaining enabled.
6768      *
6769      * @static
6770      * @memberOf _
6771      * @category Chaining
6772      * @param {*} value The value to wrap.
6773      * @returns {Object} Returns the wrapper object.
6774      * @example
6775      *
6776      * var characters = [
6777      *   { 'name': 'barney',  'age': 36 },
6778      *   { 'name': 'fred',    'age': 40 },
6779      *   { 'name': 'pebbles', 'age': 1 }
6780      * ];
6781      *
6782      * var youngest = _.chain(characters)
6783      *     .sortBy('age')
6784      *     .map(function(chr) { return chr.name + ' is ' + chr.age; })
6785      *     .first()
6786      *     .value();
6787      * // => 'pebbles is 1'
6788      */
6789     function chain(value) {
6790       value = new lodashWrapper(value);
6791       value.__chain__ = true;
6792       return value;
6793     }
6794
6795     /**
6796      * Invokes `interceptor` with the `value` as the first argument and then
6797      * returns `value`. The purpose of this method is to "tap into" a method
6798      * chain in order to perform operations on intermediate results within
6799      * the chain.
6800      *
6801      * @static
6802      * @memberOf _
6803      * @category Chaining
6804      * @param {*} value The value to provide to `interceptor`.
6805      * @param {Function} interceptor The function to invoke.
6806      * @returns {*} Returns `value`.
6807      * @example
6808      *
6809      * _([1, 2, 3, 4])
6810      *  .tap(function(array) { array.pop(); })
6811      *  .reverse()
6812      *  .value();
6813      * // => [3, 2, 1]
6814      */
6815     function tap(value, interceptor) {
6816       interceptor(value);
6817       return value;
6818     }
6819
6820     /**
6821      * Enables explicit method chaining on the wrapper object.
6822      *
6823      * @name chain
6824      * @memberOf _
6825      * @category Chaining
6826      * @returns {*} Returns the wrapper object.
6827      * @example
6828      *
6829      * var characters = [
6830      *   { 'name': 'barney', 'age': 36 },
6831      *   { 'name': 'fred',   'age': 40 }
6832      * ];
6833      *
6834      * // without explicit chaining
6835      * _(characters).first();
6836      * // => { 'name': 'barney', 'age': 36 }
6837      *
6838      * // with explicit chaining
6839      * _(characters).chain()
6840      *   .first()
6841      *   .pick('age')
6842      *   .value();
6843      * // => { 'age': 36 }
6844      */
6845     function wrapperChain() {
6846       this.__chain__ = true;
6847       return this;
6848     }
6849
6850     /**
6851      * Produces the `toString` result of the wrapped value.
6852      *
6853      * @name toString
6854      * @memberOf _
6855      * @category Chaining
6856      * @returns {string} Returns the string result.
6857      * @example
6858      *
6859      * _([1, 2, 3]).toString();
6860      * // => '1,2,3'
6861      */
6862     function wrapperToString() {
6863       return String(this.__wrapped__);
6864     }
6865
6866     /**
6867      * Extracts the wrapped value.
6868      *
6869      * @name valueOf
6870      * @memberOf _
6871      * @alias value
6872      * @category Chaining
6873      * @returns {*} Returns the wrapped value.
6874      * @example
6875      *
6876      * _([1, 2, 3]).valueOf();
6877      * // => [1, 2, 3]
6878      */
6879     function wrapperValueOf() {
6880       return this.__wrapped__;
6881     }
6882
6883     /*--------------------------------------------------------------------------*/
6884
6885     // add functions that return wrapped values when chaining
6886     lodash.after = after;
6887     lodash.assign = assign;
6888     lodash.at = at;
6889     lodash.bind = bind;
6890     lodash.bindAll = bindAll;
6891     lodash.bindKey = bindKey;
6892     lodash.chain = chain;
6893     lodash.compact = compact;
6894     lodash.compose = compose;
6895     lodash.constant = constant;
6896     lodash.countBy = countBy;
6897     lodash.create = create;
6898     lodash.createCallback = createCallback;
6899     lodash.curry = curry;
6900     lodash.debounce = debounce;
6901     lodash.defaults = defaults;
6902     lodash.defer = defer;
6903     lodash.delay = delay;
6904     lodash.difference = difference;
6905     lodash.filter = filter;
6906     lodash.flatten = flatten;
6907     lodash.forEach = forEach;
6908     lodash.forEachRight = forEachRight;
6909     lodash.forIn = forIn;
6910     lodash.forInRight = forInRight;
6911     lodash.forOwn = forOwn;
6912     lodash.forOwnRight = forOwnRight;
6913     lodash.functions = functions;
6914     lodash.groupBy = groupBy;
6915     lodash.indexBy = indexBy;
6916     lodash.initial = initial;
6917     lodash.intersection = intersection;
6918     lodash.invert = invert;
6919     lodash.invoke = invoke;
6920     lodash.keys = keys;
6921     lodash.map = map;
6922     lodash.mapValues = mapValues;
6923     lodash.max = max;
6924     lodash.memoize = memoize;
6925     lodash.merge = merge;
6926     lodash.min = min;
6927     lodash.omit = omit;
6928     lodash.once = once;
6929     lodash.pairs = pairs;
6930     lodash.partial = partial;
6931     lodash.partialRight = partialRight;
6932     lodash.pick = pick;
6933     lodash.pluck = pluck;
6934     lodash.property = property;
6935     lodash.pull = pull;
6936     lodash.range = range;
6937     lodash.reject = reject;
6938     lodash.remove = remove;
6939     lodash.rest = rest;
6940     lodash.shuffle = shuffle;
6941     lodash.sortBy = sortBy;
6942     lodash.tap = tap;
6943     lodash.throttle = throttle;
6944     lodash.times = times;
6945     lodash.toArray = toArray;
6946     lodash.transform = transform;
6947     lodash.union = union;
6948     lodash.uniq = uniq;
6949     lodash.values = values;
6950     lodash.where = where;
6951     lodash.without = without;
6952     lodash.wrap = wrap;
6953     lodash.xor = xor;
6954     lodash.zip = zip;
6955     lodash.zipObject = zipObject;
6956
6957     // add aliases
6958     lodash.collect = map;
6959     lodash.drop = rest;
6960     lodash.each = forEach;
6961     lodash.eachRight = forEachRight;
6962     lodash.extend = assign;
6963     lodash.methods = functions;
6964     lodash.object = zipObject;
6965     lodash.select = filter;
6966     lodash.tail = rest;
6967     lodash.unique = uniq;
6968     lodash.unzip = zip;
6969
6970     // add functions to `lodash.prototype`
6971     mixin(lodash);
6972
6973     /*--------------------------------------------------------------------------*/
6974
6975     // add functions that return unwrapped values when chaining
6976     lodash.clone = clone;
6977     lodash.cloneDeep = cloneDeep;
6978     lodash.contains = contains;
6979     lodash.escape = escape;
6980     lodash.every = every;
6981     lodash.find = find;
6982     lodash.findIndex = findIndex;
6983     lodash.findKey = findKey;
6984     lodash.findLast = findLast;
6985     lodash.findLastIndex = findLastIndex;
6986     lodash.findLastKey = findLastKey;
6987     lodash.has = has;
6988     lodash.identity = identity;
6989     lodash.indexOf = indexOf;
6990     lodash.isArguments = isArguments;
6991     lodash.isArray = isArray;
6992     lodash.isBoolean = isBoolean;
6993     lodash.isDate = isDate;
6994     lodash.isElement = isElement;
6995     lodash.isEmpty = isEmpty;
6996     lodash.isEqual = isEqual;
6997     lodash.isFinite = isFinite;
6998     lodash.isFunction = isFunction;
6999     lodash.isNaN = isNaN;
7000     lodash.isNull = isNull;
7001     lodash.isNumber = isNumber;
7002     lodash.isObject = isObject;
7003     lodash.isPlainObject = isPlainObject;
7004     lodash.isRegExp = isRegExp;
7005     lodash.isString = isString;
7006     lodash.isUndefined = isUndefined;
7007     lodash.lastIndexOf = lastIndexOf;
7008     lodash.mixin = mixin;
7009     lodash.noConflict = noConflict;
7010     lodash.noop = noop;
7011     lodash.now = now;
7012     lodash.parseInt = parseInt;
7013     lodash.random = random;
7014     lodash.reduce = reduce;
7015     lodash.reduceRight = reduceRight;
7016     lodash.result = result;
7017     lodash.runInContext = runInContext;
7018     lodash.size = size;
7019     lodash.some = some;
7020     lodash.sortedIndex = sortedIndex;
7021     lodash.template = template;
7022     lodash.unescape = unescape;
7023     lodash.uniqueId = uniqueId;
7024
7025     // add aliases
7026     lodash.all = every;
7027     lodash.any = some;
7028     lodash.detect = find;
7029     lodash.findWhere = find;
7030     lodash.foldl = reduce;
7031     lodash.foldr = reduceRight;
7032     lodash.include = contains;
7033     lodash.inject = reduce;
7034
7035     mixin(function() {
7036       var source = {}
7037       forOwn(lodash, function(func, methodName) {
7038         if (!lodash.prototype[methodName]) {
7039           source[methodName] = func;
7040         }
7041       });
7042       return source;
7043     }(), false);
7044
7045     /*--------------------------------------------------------------------------*/
7046
7047     // add functions capable of returning wrapped and unwrapped values when chaining
7048     lodash.first = first;
7049     lodash.last = last;
7050     lodash.sample = sample;
7051
7052     // add aliases
7053     lodash.take = first;
7054     lodash.head = first;
7055
7056     forOwn(lodash, function(func, methodName) {
7057       var callbackable = methodName !== 'sample';
7058       if (!lodash.prototype[methodName]) {
7059         lodash.prototype[methodName]= function(n, guard) {
7060           var chainAll = this.__chain__,
7061               result = func(this.__wrapped__, n, guard);
7062
7063           return !chainAll && (n == null || (guard && !(callbackable && typeof n == 'function')))
7064             ? result
7065             : new lodashWrapper(result, chainAll);
7066         };
7067       }
7068     });
7069
7070     /*--------------------------------------------------------------------------*/
7071
7072     /**
7073      * The semantic version number.
7074      *
7075      * @static
7076      * @memberOf _
7077      * @type string
7078      */
7079     lodash.VERSION = '2.4.2';
7080
7081     // add "Chaining" functions to the wrapper
7082     lodash.prototype.chain = wrapperChain;
7083     lodash.prototype.toString = wrapperToString;
7084     lodash.prototype.value = wrapperValueOf;
7085     lodash.prototype.valueOf = wrapperValueOf;
7086
7087     // add `Array` functions that return unwrapped values
7088     baseEach(['join', 'pop', 'shift'], function(methodName) {
7089       var func = arrayRef[methodName];
7090       lodash.prototype[methodName] = function() {
7091         var chainAll = this.__chain__,
7092             result = func.apply(this.__wrapped__, arguments);
7093
7094         return chainAll
7095           ? new lodashWrapper(result, chainAll)
7096           : result;
7097       };
7098     });
7099
7100     // add `Array` functions that return the existing wrapped value
7101     baseEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
7102       var func = arrayRef[methodName];
7103       lodash.prototype[methodName] = function() {
7104         func.apply(this.__wrapped__, arguments);
7105         return this;
7106       };
7107     });
7108
7109     // add `Array` functions that return new wrapped values
7110     baseEach(['concat', 'slice', 'splice'], function(methodName) {
7111       var func = arrayRef[methodName];
7112       lodash.prototype[methodName] = function() {
7113         return new lodashWrapper(func.apply(this.__wrapped__, arguments), this.__chain__);
7114       };
7115     });
7116
7117     // avoid array-like object bugs with `Array#shift` and `Array#splice`
7118     // in IE < 9, Firefox < 10, Narwhal, and RingoJS
7119     if (!support.spliceObjects) {
7120       baseEach(['pop', 'shift', 'splice'], function(methodName) {
7121         var func = arrayRef[methodName],
7122             isSplice = methodName == 'splice';
7123
7124         lodash.prototype[methodName] = function() {
7125           var chainAll = this.__chain__,
7126               value = this.__wrapped__,
7127               result = func.apply(value, arguments);
7128
7129           if (value.length === 0) {
7130             delete value[0];
7131           }
7132           return (chainAll || isSplice)
7133             ? new lodashWrapper(result, chainAll)
7134             : result;
7135         };
7136       });
7137     }
7138
7139     // add pseudo private property to be used and removed during the build process
7140     lodash._baseEach = baseEach;
7141     lodash._iteratorTemplate = iteratorTemplate;
7142     lodash._shimKeys = shimKeys;
7143
7144     return lodash;
7145   }
7146
7147   /*--------------------------------------------------------------------------*/
7148
7149   // expose Lo-Dash
7150   var _ = runInContext();
7151
7152   // some AMD build optimizers like r.js check for condition patterns like the following:
7153   if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
7154     // Expose Lo-Dash to the global object even when an AMD loader is present in
7155     // case Lo-Dash is loaded with a RequireJS shim config.
7156     // See http://requirejs.org/docs/api.html#config-shim
7157     root._ = _;
7158
7159     // define as an anonymous module so, through path mapping, it can be
7160     // referenced as the "underscore" module
7161     define(function() {
7162       return _;
7163     });
7164   }
7165   // check for `exports` after `define` in case a build optimizer adds an `exports` object
7166   else if (freeExports && freeModule) {
7167     // in Node.js or RingoJS
7168     if (moduleExports) {
7169       (freeModule.exports = _)._ = _;
7170     }
7171     // in Narwhal or Rhino -require
7172     else {
7173       freeExports._ = _;
7174     }
7175   }
7176   else {
7177     // in a browser or Rhino
7178     root._ = _;
7179   }
7180 }.call(this));