diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 34b66d2ed..c3ab571df 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -9,13 +9,13 @@ */ ;(function() { - /** Used as a safe reference for `undefined` in pre ES5 environments */ + /** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined; - /** Used as the semantic version number */ + /** Used as the semantic version number. */ var VERSION = '3.0.0-pre'; - /** Used to compose bitmasks for wrapper metadata */ + /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_FLAG = 4, @@ -25,38 +25,38 @@ PARTIAL_RIGHT_FLAG = 64, REARG_FLAG = 128; - /** Used as default options for `_.trunc` */ + /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...'; - /** Used to detect when a function becomes hot */ + /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150, HOT_SPAN = 16; - /** Used to indicate the type of lazy iteratees */ + /** Used to indicate the type of lazy iteratees. */ var LAZY_FILTER_FLAG = 0, LAZY_MAP_FLAG = 1, LAZY_WHILE_FLAG = 2; - /** Used as the `TypeError` message for "Functions" methods */ + /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; - /** Used as the internal argument placeholder */ + /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; - /** Used to generate unique IDs */ + /** Used to generate unique IDs. */ var idCounter = 0; - /** Used to match empty string literals in compiled template source */ + /** Used to match empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - /** Used to match HTML entities and HTML characters */ + /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g; - /** Used to match template delimiters */ + /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; @@ -68,22 +68,22 @@ */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - /** Used to match `RegExp` flags from their coerced string values */ + /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; - /** Used to detect named functions */ + /** Used to detect named functions. */ var reFuncName = /^\s*function[ \n\r\t]+\w/; - /** Used to detect hexadecimal string values */ + /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; - /** Used to detect host constructors (Safari > 5) */ + /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters (excluding mathematical operators) */ + /** Used to match latin-1 supplement letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; - /** Used to ensure capturing order of template delimiters */ + /** Used to ensure capturing order of template delimiters. */ var reNoMatch = /($^)/; /** @@ -93,13 +93,13 @@ */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g; - /** Used to detect functions containing a `this` reference */ + /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; - /** Used to match unescaped characters in compiled string literals */ + /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - /** Used to match words to create compound words */ + /** Used to match words to create compound words. */ var reWords = (function() { var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; @@ -107,19 +107,19 @@ return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); - /** Used to detect and test whitespace */ + /** Used to detect and test for whitespace. */ var whitespace = ( - // whitespace + // Basic whitespace characters. ' \t\x0b\f\xa0\ufeff' + - // line terminators + // Line terminators. '\n\r\u2028\u2029' + - // unicode category "Zs" space separators + // Unicode category "Zs" space separators. '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); - /** Used to assign default `context` object properties */ + /** Used to assign default `context` object properties. */ var contextProps = [ 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', @@ -129,16 +129,16 @@ 'window', 'WinRTError' ]; - /** Used to fix the JScript `[[DontEnum]]` bug */ - var shadowedProps = [ + /** Used to fix the JScript `[[DontEnum]]` bug. */ + var shadowProps = [ 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf' ]; - /** Used to make template sourceURLs easier to identify */ + /** Used to make template sourceURLs easier to identify. */ var templateCounter = -1; - /** `Object#toString` result references */ + /** `Object#toString` result references. */ var argsClass = '[object Arguments]', arrayClass = '[object Array]', boolClass = '[object Boolean]', @@ -164,7 +164,7 @@ uint16Class = '[object Uint16Array]', uint32Class = '[object Uint32Array]'; - /** Used to identify object classifications that are treated like arrays */ + /** Used to identify object classifications that are treated like arrays. */ var arrayLikeClasses = {}; arrayLikeClasses[argsClass] = arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = @@ -179,7 +179,7 @@ arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; - /** Used to identify object classifications that `_.clone` supports */ + /** Used to identify object classifications that `_.clone` supports. */ var cloneableClasses = {}; cloneableClasses[argsClass] = cloneableClasses[arrayClass] = cloneableClasses[arrayBufferClass] = cloneableClasses[boolClass] = @@ -194,14 +194,14 @@ cloneableClasses[funcClass] = cloneableClasses[mapClass] = cloneableClasses[setClass] = cloneableClasses[weakMapClass] = false; - /** Used as an internal `_.debounce` options object by `_.throttle` */ + /** Used as an internal `_.debounce` options object by `_.throttle`. */ var debounceOptions = { 'leading': false, 'maxWait': 0, 'trailing': false }; - /** Used to map latin-1 supplementary letters to basic latin letters */ + /** Used to map latin-1 supplementary letters to basic latin letters. */ var deburredLetters = { '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', @@ -222,20 +222,7 @@ '\xdf': 'ss' }; - /** - * Used to map characters to HTML entities. - * - * **Note:** Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't require escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), - * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of - * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. - */ + /** Used to map characters to HTML entities. */ var htmlEscapes = { '&': '&', '<': '<', @@ -245,7 +232,7 @@ '`': '`' }; - /** Used to map HTML entities to characters */ + /** Used to map HTML entities to characters. */ var htmlUnescapes = { '&': '&', '<': '<', @@ -255,13 +242,13 @@ '`': '`' }; - /** Used to determine if values are of the language type `Object` */ + /** Used to determine if values are of the language type `Object`. */ var objectTypes = { 'function': true, 'object': true }; - /** Used to escape characters for inclusion in compiled string literals */ + /** Used to escape characters for inclusion in compiled string literals. */ var stringEscapes = { '\\': '\\', "'": "'", @@ -279,19 +266,19 @@ */ var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; - /** Detect free variable `exports` */ + /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `module` */ + /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; } - /** Detect the popular CommonJS extension `module.exports` */ + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /*--------------------------------------------------------------------------*/ @@ -542,6 +529,26 @@ return result; } + /** + * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` + * to define the sort order of `array` and replaces criteria objects with their + * corresponding values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + /** * Used by `_.max` and `_.min` as the default callback for string values. * @@ -587,7 +594,7 @@ } /** - * Used by `_.sortBy` to compare transformed elements of `collection` and stable + * Used by `_.sortBy` to compare transformed elements of a collection and stable * sort them in ascending order. * * @private @@ -600,8 +607,8 @@ } /** - * Used by `_.sortBy` to compare multiple properties of each element in a - * collection and stable sort them in ascending order. + * Used by `_.sortByAll` to compare multiple properties of each element + * in a collection and stable sort them in ascending order. * * @private * @param {Object} object The object to compare to `other`. @@ -622,7 +629,7 @@ } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provide the same value - // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247. // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90. @@ -700,8 +707,8 @@ return function() { return false; }; } return function(value) { - // IE < 9 presents many host objects as `Object` objects that can coerce to - // strings despite having improperly defined `toString` methods + // IE < 9 presents many host objects as `Object` objects that can coerce + // to strings despite having improperly defined `toString` methods. return typeof value.toString != 'function' && typeof (value + '') == 'string'; }; }()); @@ -862,7 +869,7 @@ // See http://es5.github.io/#x11.1.5. context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - /** Native constructor references */ + /** Native constructor references. */ var Array = context.Array, Date = context.Date, Error = context.Error, @@ -874,34 +881,34 @@ String = context.String, TypeError = context.TypeError; - /** Used for native method references */ + /** Used for native method references. */ var arrayProto = Array.prototype, errorProto = Error.prototype, objectProto = Object.prototype, stringProto = String.prototype; - /** Used to detect DOM support */ + /** Used to detect DOM support. */ var document = (document = context.window) && document.document; - /** Used to resolve the decompiled source of functions */ + /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; - /** Used to check objects for own properties */ + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - /** Used to restore the original `_` reference in `_.noConflict` */ + /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; - /** Used to resolve the internal `[[Class]]` of values */ + /** Used to resolve the internal `[[Class]]` of values. */ var toString = objectProto.toString; - /** Used to detect if a method is native */ + /** Used to detect if a method is native. */ var reNative = RegExp('^' + escapeRegExp(toString) .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); - /** Native method references */ + /** Native method references. */ var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, ceil = Math.ceil, @@ -917,11 +924,11 @@ unshift = arrayProto.unshift, WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; - /** Used to clone array buffers */ + /** Used to clone array buffers. */ var Float64Array = (function() { // Safari 5 errors when using an array buffer to initialize a typed array // where the array buffer's `byteLength` is not a multiple of the typed - // array's `BYTES_PER_ELEMENT` + // array's `BYTES_PER_ELEMENT`. try { var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func; @@ -929,7 +936,7 @@ return result; }()); - /* Native method references for those with the same name as other `lodash` methods */ + /* Native method references for those with the same name as other `lodash` methods. */ var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, @@ -941,15 +948,15 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used as references for `-Infinity` and `Infinity` */ + /** Used as references for `-Infinity` and `Infinity`. */ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - /** Used as references for the max length and index of an array */ + /** Used as references for the max length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - /** Used as the size, in bytes, of each Float64Array element */ + /** Used as the size, in bytes, of each Float64Array element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** @@ -959,10 +966,10 @@ */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - /** Used to store function metadata */ + /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; - /** Used to lookup a built-in constructor by `[[Class]]` */ + /** Used to lookup a built-in constructor by `[[Class]]`. */ var ctorByClass = {}; ctorByClass[float32Class] = context.Float32Array; ctorByClass[float64Class] = context.Float64Array; @@ -974,14 +981,14 @@ ctorByClass[uint16Class] = context.Uint16Array; ctorByClass[uint32Class] = context.Uint32Array; - /** Used to avoid iterating over non-enumerable properties in IE < 9 */ + /** Used to avoid iterating over non-enumerable properties in IE < 9. */ var nonEnumProps = {}; nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }; nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true }; nonEnumProps[errorClass] = nonEnumProps[funcClass] = nonEnumProps[regexpClass] = { 'constructor': true, 'toString': true }; nonEnumProps[objectClass] = { 'constructor': true }; - arrayEach(shadowedProps, function(key) { + arrayEach(shadowProps, function(key) { for (var className in nonEnumProps) { if (hasOwnProperty.call(nonEnumProps, className)) { var props = nonEnumProps[className]; @@ -1014,22 +1021,22 @@ * `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`, * `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, * `rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, - * `sortBy`, `splice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, - * `tap`, `throttle`, `thru`, `times`, `toArray`, `transform`, `union`, `uniq`, - * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, - * `zip`, and `zipObject` + * `sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `transform`, + * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, + * `without`, `wrap`, `xor`, `zip`, and `zipObject` * * The non-chainable wrapper functions are: - * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `contains`, - * `deburr`, endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, - * `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, isDate`, - * `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, `isFunction`, - * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, - * `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, `last`, - * `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, `padRight`, - * `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, - * `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, + * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, + * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, + * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, + * `isFunction`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, + * `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, + * `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, + * `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, * `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, * `trunc`, `unescape`, `uniqueId`, `value`, and `words` * @@ -1064,7 +1071,7 @@ return value; } if (hasOwnProperty.call(value, '__wrapped__')) { - return new LodashWrapper(value.__wrapped__, value.__chain__, baseSlice(value.__queue__)); + return new LodashWrapper(value.__wrapped__, value.__chain__, baseSlice(value.__actions__)); } } return new LodashWrapper(value); @@ -1076,11 +1083,11 @@ * @private * @param {*} value The value to wrap. * @param {boolean} [chainAll=false] Enable chaining for all wrapper methods. - * @param {Array} [queue=[]] Actions to peform to resolve the unwrapped value. + * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. */ - function LodashWrapper(value, chainAll, queue) { + function LodashWrapper(value, chainAll, actions) { + this.__actions__ = actions || []; this.__chain__ = !!chainAll; - this.__queue__ = queue || []; this.__wrapped__ = value; } @@ -1246,8 +1253,8 @@ }(0, 0)); /** - * By default, the template delimiters used by Lo-Dash are similar to those - * in embedded Ruby (ERB). Change the following template settings to use + * By default, the template delimiters used by Lo-Dash are like those in + * embedded Ruby (ERB). Change the following template settings to use * alternative delimiters. * * @static @@ -1315,6 +1322,7 @@ * @param {*} value The value to wrap. */ function LazyWrapper(value) { + this.actions = null; this.dir = 1; this.dropCount = 0; this.filtered = false; @@ -1333,10 +1341,12 @@ * @returns {Object} Returns the cloned `LazyWrapper` object. */ function lazyClone() { - var iteratees = this.iteratees, + var actions = this.actions, + iteratees = this.iteratees, views = this.views, result = new LazyWrapper(this.wrapped); + result.actions = actions ? baseSlice(actions) : null; result.dir = this.dir; result.dropCount = this.dropCount; result.filtered = this.filtered; @@ -1372,8 +1382,11 @@ * @returns {*} Returns the unwrapped value. */ function lazyValue() { - var array = this.wrapped.value(), - dir = this.dir, + var array = this.wrapped.value(); + if (!isArray(array)) { + return baseWrapperValue(array, this.actions); + } + var dir = this.dir, isRight = dir < 0, length = array.length, view = getView(0, length, this.views), @@ -1433,6 +1446,19 @@ this.__data__ = {}; } + /** + * Removes `key` and its value from the cache. + * + * @private + * @name delete + * @memberOf _.memoize.Cache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`. + */ + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + /** * Gets the cached value for `key`. * @@ -1443,7 +1469,7 @@ * @returns {*} Returns the cached value. */ function mapGet(key) { - return this.__data__[key]; + return key == '__proto__' ? undefined : this.__data__[key]; } /** @@ -1678,8 +1704,7 @@ } /** - * The base implementation of `_.callback` without support for creating - * "_.pluck" and "_.where" style callbacks. + * The base implementation of `_.callback`. * * @private * @param {*} [func=_.identity] The value to convert to a callback. @@ -1707,13 +1732,13 @@ data = !reFuncName.test(source); } if (!data) { - // checks if `func` references the `this` keyword and stores the result + // Check if `func` references the `this` keyword and store the result. data = reThis.test(source) || isNative(func); baseSetData(func, data); } } } - // exit early if there are no `this` references or `func` is bound + // Exit early if there are no `this` references or `func` is bound. if (data === false || (data !== true && data[1] & BIND_FLAG)) { return func; } @@ -1738,7 +1763,7 @@ if (func == null) { return identity; } - // handle "_.pluck" and "_.where" style callback shorthands + // Handle "_.pluck" and "_.where" style callback shorthands. return type == 'object' ? matches(func) : property(func); } @@ -1780,7 +1805,7 @@ if (!isDeep || result === value) { return result; } - // check for circular references and return corresponding clone + // Check for circular references and return corresponding clone. stackA || (stackA = []); stackB || (stackB = []); @@ -1790,12 +1815,11 @@ return stackB[length]; } } - // add the source value to the stack of traversed objects - // and associate it with its clone + // Add the source value to the stack of traversed objects and associate it with its clone. stackA.push(value); stackB.push(result); - // recursively populate clone (susceptible to call stack limits) + // Recursively populate clone (susceptible to call stack limits). (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); }); @@ -1813,7 +1837,7 @@ function baseCreate(prototype) { return isObject(prototype) ? nativeCreate(prototype) : {}; } - // fallback for environments without `Object.create` + // Fallback for environments without `Object.create`. if (!nativeCreate) { baseCreate = (function() { function Object() {} @@ -1838,15 +1862,16 @@ * @returns {Array} Returns the new array of filtered values. */ function baseDifference(array, values) { - var length = array ? array.length : 0; + var length = array ? array.length : 0, + result = []; + if (!length) { - return []; + return result; } var index = -1, indexOf = getIndexOf(), isCommon = indexOf == baseIndexOf, cache = isCommon && values.length >= 200 && createCache(values), - result = [], valuesLength = values.length; if (cache) { @@ -2009,7 +2034,7 @@ if (value && typeof value == 'object' && typeof value.length == 'number' && (isArray(value) || isArguments(value))) { - // recursively flatten arrays (susceptible to call stack limits) + // Recursively flatten arrays (susceptible to call stack limits). if (isDeep) { value = baseFlatten(value, isDeep, isStrict); } @@ -2155,19 +2180,19 @@ * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { - var result = customizer && !stackA ? customizer(value, other) : undefined; + var result = (customizer && !stackA) ? customizer(value, other) : undefined; if (typeof result != 'undefined') { return !!result; } - // exit early for identical values + // Exit early for identical values. if (value === other) { - // treat `+0` vs. `-0` as not equal + // Treat `+0` vs. `-0` as not equal. return value !== 0 || (1 / value == 1 / other); } var valType = typeof value, othType = typeof other; - // exit early for unlike primitive values + // Exit early for unlike primitive values. if (!(valType == 'number' && othType == 'number') && (value == null || other == null || (valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object'))) { return false; @@ -2198,7 +2223,7 @@ } } else { - // unwrap any `lodash` wrapped values + // Unwrap `lodash` wrapped values. var valWrapped = valIsObj && hasOwnProperty.call(value, '__wrapped__'), othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); @@ -2213,12 +2238,12 @@ valIsArg = isArguments(value); othIsArg = isArguments(other); } - // in older versions of Opera, `arguments` objects have `Array` constructors + // In older versions of Opera, `arguments` objects have `Array` constructors. var valCtor = valIsArg ? Object : value.constructor, othCtor = othIsArg ? Object : other.constructor; if (valIsErr) { - // error objects of different types are not equal + // Error objects of different types are not equal. if (valCtor.prototype.name != othCtor.prototype.name) { return false; } @@ -2231,7 +2256,7 @@ return false; } if (!valHasCtor) { - // non `Object` object instances with different constructors are not equal + // Non `Object` object instances with different constructors are not equal. if (valCtor != othCtor && ('constructor' in value && 'constructor' in other) && !(typeof valCtor == 'function' && valCtor instanceof valCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { @@ -2258,29 +2283,29 @@ switch (valClass) { case boolClass: case dateClass: - // coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. return +value == +other; case numberClass: - // treat `NaN` vs. `NaN` as equal + // Treat `NaN` vs. `NaN` as equal. return (value != +value) ? other != +other - // but treat `-0` vs. `+0` as not equal + // But, treat `-0` vs. `+0` as not equal. : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); case regexpClass: case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and - // treat strings primitives and string objects as equal + // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and + // treat strings primitives and string objects as equal. return value == String(other); } return false; } } - // assume cyclic structures are equal - // the algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) + // Assume cyclic structures are equal. + // The algorithm for detecting cyclic structures is adapted from ES 5.1 + // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). stackA || (stackA = []); stackB || (stackB = []); @@ -2290,14 +2315,14 @@ return stackB[index] == other; } } - // add `value` and `other` to the stack of traversed objects + // Add `value` and `other` to the stack of traversed objects. stackA.push(value); stackB.push(other); - // recursively compare objects and arrays (susceptible to call stack limits) + // Recursively compare objects and arrays (susceptible to call stack limits). result = true; if (valIsArr) { - // deep compare the contents, ignoring non-numeric properties + // Deep compare the contents, ignoring non-numeric properties. while (result && ++index < valLength) { var valValue = value[index]; if (isWhere) { @@ -2353,11 +2378,8 @@ var index = -1, isFunc = typeof methodName == 'function', length = collection ? collection.length : 0, - result = []; + result = isLength(length) ? Array(length) : []; - if (isLength(length)) { - result.length = length; - } baseEach(collection, function(value) { var func = isFunc ? methodName : (value != null && value[methodName]); result[++index] = func ? func.apply(value, args) : undefined; @@ -2413,7 +2435,7 @@ } return; } - // avoid merging previously merged cyclic sources + // Avoid merging previously merged cyclic sources. stackA || (stackA = []); stackB || (stackB = []); @@ -2432,12 +2454,12 @@ ? (isArray(value) ? value : []) : (isPlainObject(value) ? value : {}); } - // add the source value to the stack of traversed objects - // and associate it with its merged value + // Add the source value to the stack of traversed objects and associate + // it with its merged value. stackA.push(srcValue); stackB.push(result); - // recursively merge objects and arrays (susceptible to call stack limits) + // Recursively merge objects and arrays (susceptible to call stack limits). if (isDeep) { baseMerge(result, srcValue, customizer, stackA, stackB); } @@ -2486,7 +2508,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight` without support * for callback shorthands or `this` binding, which iterates over `collection` - * usingthe provided `eachFunc`. + * using the provided `eachFunc`. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2656,6 +2678,35 @@ return result; } + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to peform to resolve the unwrapped value. + * @returns {*} Returns the resolved unwrapped value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, + length = actions.length; + + while (++index < length) { + var args = [result], + action = actions[index], + object = action.object; + + push.apply(args, action.args); + result = object[action.name].apply(object, args); + } + return result; + } + /** * Creates a clone of the given array buffer. * @@ -2667,8 +2718,8 @@ return bufferSlice.call(buffer, 0); } if (!bufferSlice) { - // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` - bufferClone = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`. + bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) { var byteLength = buffer.byteLength, floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, @@ -2813,7 +2864,7 @@ if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { length = 2; } - // juggle arguments + // Juggle arguments. if (length > 3 && typeof arguments[length - 2] == 'function') { var customizer = baseCallback(arguments[--length - 1], arguments[length--], 5); } else if (length > 2 && typeof arguments[length - 1] == 'function') { @@ -2891,8 +2942,8 @@ var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, arguments); - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 + // Mimic the constructor's `return` behavior. + // See http://es5.github.io/#x13.2.2. return isObject(result) ? result : thisBinding; }; } @@ -2924,6 +2975,8 @@ key = func; function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it to other functions. var length = arguments.length, index = length, args = Array(length); @@ -2998,23 +3051,23 @@ /** * Creates a function that wraps `func` and invokes it with the optional `this` - * binding of `thisArg` and the `partialArgs` prepended to those provided to + * binding of `thisArg` and the `partials` prepended to those provided to * the wrapper. * * @private * @param {Function} func The function to partially apply arguments to. * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} thisArg The `this` binding of `func`. * @param {Array} partials The arguments to prepend to those provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. * @returns {Function} Returns the new bound function. */ - function createPartialWrapper(func, bitmask, partials, thisArg) { + function createPartialWrapper(func, bitmask, thisArg, partials) { var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { - // avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it to `composeArgs` + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it `func`. var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, @@ -3050,7 +3103,7 @@ * 128 - `_.rearg` * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partialArgs` placeholder indexes. + * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. @@ -3065,83 +3118,35 @@ bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); partials = holders = null; } - if (partials && !holders) { - holders = []; - } - var oldPartials = partials, - oldHolders = holders, - isPartial = bitmask & PARTIAL_FLAG, - isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; + holders = (partials && !holders) ? [] : holders; + length -= (holders ? holders.length : 0); - if (!isPartial) { + if (bitmask & PARTIAL_RIGHT_FLAG) { var partialsRight = partials, holdersRight = holders; partials = holders = null; } - var data = (data = !isBindKey && getData(func)) && data !== true && data; - if (data) { - var funcBitmask = data[1], - funcIsBind = funcBitmask & BIND_FLAG, - isBind = bitmask & BIND_FLAG; + var data = !isBindKey && getData(func), + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity]; - // use metadata `func` and merge bitmasks - func = data[0]; - bitmask |= funcBitmask; + if (data && data !== true && !(argPos && (data[3] || data[5]))) { + newData = mergeData(newData, data); + } + newData[8] = newData[8] == null + ? (isBindKey ? 0 : newData[0].length) + : nativeMax(newData[8] - length, 0) || 0; - // use metadata `thisArg` if available - if (funcIsBind) { - thisArg = data[2]; - } - // set if currying a bound function - if (!isBind && funcIsBind) { - bitmask |= CURRY_BOUND_FLAG; - } - // compose partial arguments - var value = data[3]; - if (value) { - var funcHolders = data[4]; - partials = isPartial ? composeArgs(partials, value, funcHolders) : baseSlice(value); - holders = isPartial ? replaceHolders(partials, PLACEHOLDER) : baseSlice(funcHolders); - } - // compose partial right arguments - value = data[5]; - if (value) { - funcHolders = data[6]; - partialsRight = isPartialRight ? composeArgsRight(partialsRight, value, funcHolders) : baseSlice(value); - holdersRight = isPartialRight ? replaceHolders(partialsRight, PLACEHOLDER) : baseSlice(funcHolders); - } - // append argument positions - value = data[7]; - if (value) { - value = baseSlice(value); - if (argPos) { - push.apply(value, argPos); - } - argPos = value; - } - // use metadata `arity` if not provided - if (arity == null) { - arity = data[8]; - } - } - if (arity == null) { - arity = isBindKey ? 0 : func.length; - } else { - arity = nativeMax(+arity || 0, 0); - } - if (oldPartials) { - arity = nativeMax(arity - (oldPartials.length - oldHolders.length), 0); - } + bitmask = newData[1]; if (bitmask == BIND_FLAG) { - var result = createBindWrapper(func, thisArg); - } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) { - result = createPartialWrapper(func, bitmask, partials, thisArg); + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(null, newData); } else { - result = createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity); + result = createHybridWrapper.apply(null, newData); } var setter = data ? baseSetData : setData; - return setter(result, [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity]); + return setter(result, newData); } /** @@ -3231,7 +3236,7 @@ result[index] = array[index]; } } - // add array properties assigned by `RegExp#exec` + // Add array properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; @@ -3245,7 +3250,8 @@ * @private * @param {Object} object The object to clone. * @param {boolean} [isDeep=false] Specify a deep clone. - * @returns {null|Object} Returns the initialized object clone. + * @returns {null|Object} Returns the initialized object clone if an object + * is cloneable, else `null`. */ function initObjectClone(object, isDeep) { if (!isCloneable(object)) { @@ -3277,7 +3283,7 @@ case float32Class: case float64Class: case int8Class: case int16Class: case int32Class: case uint8Class: case uint8ClampedClass: case uint16Class: case uint32Class: - // Safari 5 mobile incorrectly has `Object` as the constructor + // Safari 5 mobile incorrectly has `Object` as the constructor of typed arrays. if (Ctor instanceof Ctor) { Ctor = ctorByClass[className]; } @@ -3342,7 +3348,7 @@ } /** - * Checks if `value` is valid array-like length. + * Checks if `value` is a valid array-like length. * * @private * @param {*} value The value to check. @@ -3364,6 +3370,56 @@ return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); } + /** + * Merges the function metadata of `source` into `data`. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + funcBitmask = source[1]; + + // Use metadata `thisArg` if available. + if (funcBitmask & BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + bitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : baseSlice(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : baseSlice(source[4]); + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]); + } + // Append argument positions. + value = source[7]; + if (value) { + value = baseSlice(value); + push.apply(value, data[7]); + data[7] = value; + } + // Use metadata `arity` if one is not provided. + if (data[8] == null) { + data[8] = source[8]; + } + // Use metadata `func` and merge bitmasks. + data[0] = source[0]; + data[1] = bitmask | funcBitmask; + + return data; + } + /** * A specialized version of `_.pick` that picks `object` properties * specified by the `props` array. @@ -3435,8 +3491,8 @@ * Sets metadata for `func`. * * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity - * function to avoid garbage collection pauses. + * period of time, it will trip its breaker and transition to an identity function + * to avoid garbage collection pauses in V8. See https://code.google.com/p/v8/issues/detail?id=2070. * * @private * @param {Function} func The function to associate metadata with. @@ -3476,7 +3532,7 @@ var Ctor, support = lodash.support; - // exit early for non `Object` objects + // Exit early for non `Object` objects. if (!(value && typeof value == 'object' && toString.call(value) == objectClass && !isHostObject(value)) || (!hasOwnProperty.call(value, 'constructor') && @@ -3598,8 +3654,11 @@ * // => [['a', 'b', 'c'], ['d']] */ function chunk(array, size, guard) { - size = (guard || size == null) ? 1 : nativeMax(+size || 1, 1); - + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(+size || 1, 1); + } var index = 0, length = array ? array.length : 0, resIndex = -1, @@ -3699,7 +3758,9 @@ * // => [1, 2, 3] */ function drop(array, n, guard) { - n = (guard || n == null) ? 1 : n; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } return slice(array, n < 0 ? 0 : n); } @@ -3729,9 +3790,10 @@ * // => [1, 2, 3] */ function dropRight(array, n, guard) { - var length = array ? array.length : 0; - n = (guard || n == null) ? 1 : n; - n = length - (n || 0); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = array ? (array.length - (+n || 0)) : 0; return slice(array, 0, n < 0 ? 0 : n); } @@ -3916,7 +3978,7 @@ * // => 2 * * // using "_.where" callback shorthand - * _.findLastIndex(users, { 'age': 40}); + * _.findLastIndex(users, { 'age': 40 }); * // => 1 * * // using "_.pluck" callback shorthand @@ -3978,7 +4040,10 @@ */ function flatten(array, isDeep, guard) { var length = array ? array.length : 0; - return length ? baseFlatten(array, guard ? false : isDeep) : []; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; } /** @@ -4002,8 +4067,8 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` * using `SameValueZero` for equality comparisons. If `fromIndex` is negative, - * it is used as the offset from the end of the collection. If `array` is - * sorted providing `true` for `fromIndex` performs a faster binary search. + * it is used as the offset from the end of `array`. If `array` is sorted + * providing `true` for `fromIndex` performs a faster binary search. * * **Note:** `SameValueZero` comparisons are like strict equality comparisons, * e.g. `===`, except that `NaN` matches `NaN`. See the @@ -4479,7 +4544,9 @@ * // => [] */ function take(array, n, guard) { - n = (guard || n == null) ? 1 : n; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } return slice(array, 0, n < 0 ? 0 : n); } @@ -4509,9 +4576,10 @@ * // => [] */ function takeRight(array, n, guard) { - var length = array ? array.length : 0; - n = (guard || n == null) ? 1 : n; - n = length - (n || 0); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = array ? (array.length - (+n || 0)) : 0; return slice(array, n < 0 ? 0 : n); } @@ -4688,7 +4756,7 @@ if (!length) { return []; } - // juggle arguments + // Juggle arguments. if (typeof isSorted != 'boolean' && isSorted != null) { thisArg = iteratee; iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; @@ -4869,10 +4937,10 @@ * ]; * * var youngest = _.chain(users) - * .sortBy('age') - * .map(function(chr) { return chr.user + ' is ' + chr.age; }) - * .first() - * .value(); + * .sortBy('age') + * .map(function(chr) { return chr.user + ' is ' + chr.age; }) + * .first() + * .value(); * // => 'pebbles is 1' */ function chain(value) { @@ -4950,9 +5018,9 @@ * // with explicit chaining * _(users).chain() * .first() - * .pick('age') + * .pick('user') * .value(); - * // => { 'age': 36 } + * // => { 'user': 'barney' } */ function wrapperChain() { return chain(this); @@ -4964,7 +5032,7 @@ * * **Note:** This method mutates the wrapped array. * - * @name chain + * @name reverse * @memberOf _ * @category Chain * @returns {Object} Returns the new reversed `lodash` object. @@ -4979,6 +5047,10 @@ * // => [3, 2, 1] */ function wrapperReverse() { + var value = this.__wrapped__; + if (value instanceof LazyWrapper) { + return new LodashWrapper(value.reverse()); + } return this.thru(function(value) { return value.reverse(); }); @@ -5003,41 +5075,25 @@ /** * Extracts the unwrapped value from its wrapper. * - * @name valueOf + * @name value * @memberOf _ - * @alias toJSON, value + * @alias toJSON, valueOf * @category Chain - * @returns {*} Returns the unwrapped value. + * @returns {*} Returns the resolved unwrapped value. * @example * - * _([1, 2, 3]).valueOf(); + * _([1, 2, 3]).value(); * // => [1, 2, 3] */ - function wrapperValueOf() { - var result = this.__wrapped__; - if (result instanceof LazyWrapper) { - result = result.value(); - } - var index = -1, - queue = this.__queue__, - length = queue.length; - - while (++index < length) { - var args = [result], - data = queue[index], - object = data.object; - - push.apply(args, data.args); - result = object[data.name].apply(object, args); - } - return result; + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); } /*------------------------------------------------------------------------*/ /** * Creates an array of elements corresponding to the specified keys, or indexes, - * of the collection. Keys may be specified as individual arguments or as arrays + * of `collection`. Keys may be specified as individual arguments or as arrays * of keys. * * @static @@ -5065,7 +5121,7 @@ /** * Checks if `value` is in `collection` using `SameValueZero` for equality * comparisons. If `fromIndex` is negative, it is used as the offset from - * the end of the collection. + * the end of `collection`. * * **Note:** `SameValueZero` comparisons are like strict equality comparisons, * e.g. `===`, except that `NaN` matches `NaN`. See the @@ -5074,7 +5130,7 @@ * * @static * @memberOf _ - * @alias include + * @alias contains, include * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {*} target The value to search for. @@ -5082,19 +5138,19 @@ * @returns {boolean} Returns `true` if a matching element is found, else `false`. * @example * - * _.contains([1, 2, 3], 1); + * _.includes([1, 2, 3], 1); * // => true * - * _.contains([1, 2, 3], 1, 2); + * _.includes([1, 2, 3], 1, 2); * // => false * - * _.contains({ 'user': 'fred', 'age': 40 }, 'fred'); + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); * // => true * - * _.contains('pebbles', 'eb'); + * _.includes('pebbles', 'eb'); * // => true */ - function contains(collection, target, fromIndex) { + function includes(collection, target, fromIndex) { var length = collection ? collection.length : 0; if (!isLength(length)) { @@ -5339,11 +5395,11 @@ * { 'user': 'fred', 'age': 40, 'status': 'busy' } * ]; * - * _.findWhere(users, { 'status': 'busy' }); - * // => { 'user': 'barney', 'age': 36, 'status': 'busy' } + * _.result(_.findWhere(users, { 'status': 'busy' }), 'user'); + * // => 'barney' * - * _.findWhere(users, { 'age': 40 }); - * // => { 'user': 'fred', 'age': 40, 'status': 'busy' } + * _.result(_.findWhere(users, { 'age': 40 }), 'user'); + * // => 'fred' */ function findWhere(collection, source) { return find(collection, matches(source)); @@ -5449,7 +5505,7 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iteratee`. The corresponding value + * each element of `collection` through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). @@ -5491,10 +5547,10 @@ }); /** - * Invokes the method named by `methodName` on each element in the collection, + * Invokes the method named by `methodName` on each element in `collection`, * returning an array of the results of each invoked method. Any additional * arguments are provided to each invoked method. If `methodName` is a function - * it is invoked for, and `this` bound to, each element in the collection. + * it is invoked for, and `this` bound to, each element in `collection`. * * @static * @memberOf _ @@ -5517,7 +5573,7 @@ } /** - * Creates an array of values by running each element in the collection through + * Creates an array of values by running each element in `collection` through * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * @@ -5547,8 +5603,8 @@ * // => [3, 6, 9] (iteration order is not guaranteed) * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * // using "_.pluck" callback shorthand @@ -5563,11 +5619,11 @@ } /** - * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iteratee function is provided it - * is invoked for each value in the collection to generate the criterion by - * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of `collection`. If `collection` is empty or + * falsey `-Infinity` is returned. If an iteratee function is provided it is + * invoked for each value in `collection` to generate the criterion by which + * the value is ranked. The `iteratee` is bound to `thisArg` and invoked with + * three arguments; (value, index, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -5634,11 +5690,11 @@ } /** - * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iteratee function is provided it - * is invoked for each value in the collection to generate the criterion by - * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of `collection`. If `collection` is empty or + * falsey `Infinity` is returned. If an iteratee function is provided it is + * invoked for each value in `collection` to generate the criterion by which + * the value is ranked. The `iteratee` is bound to `thisArg` and invoked with + * three arguments; (value, index, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -5753,7 +5809,7 @@ }, function() { return [[], []]; }); /** - * Retrieves the value of a specified property from all elements in the collection. + * Retrieves the value of a specified property from all elements in `collection`. * * @static * @memberOf _ @@ -5780,10 +5836,10 @@ } /** - * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iteratee`, where each successive + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` through `iteratee`, where each successive * invocation is supplied the return value of the previous. If `accumulator` - * is not provided the first element of the collection is used as the initial + * is not provided the first element of `collection` is used as the initial * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * @@ -5902,7 +5958,7 @@ * // => [3, 1] */ function sample(collection, n, guard) { - if (guard || n == null) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { collection = toIterable(collection); var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; @@ -5945,7 +6001,7 @@ } /** - * Gets the size of the collection by returning `collection.length` for + * Gets the size of `collection` by returning `collection.length` for * array-like values or the number of own enumerable properties for objects. * * @static @@ -6029,9 +6085,6 @@ * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an array of property names is provided for `iteratee` the collection - * is sorted by each property value. - * * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. @@ -6041,8 +6094,8 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Array|Function|Object|string} [iteratee=_.identity] The function - * invoked per iteration. If property name(s) or an object is provided it - * is used to create a "_.pluck" or "_.where" style callback respectively. + * invoked per iteration. If a property name or an object is provided it is + * used to create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example @@ -6054,55 +6107,74 @@ * // => [3, 1, 2] * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 26 }, - * { 'user': 'fred', 'age': 30 } + * { 'user': 'fred' }, + * { 'user': 'pebbles' }, + * { 'user': 'barney' } * ]; * * // using "_.pluck" callback shorthand - * _.map(_.sortBy(users, 'age'), _.values); - * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]] - * - * // sorting by multiple properties - * _.map(_.sortBy(users, ['user', 'age']), _.values); - * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + * _.pluck(_.sortBy(users, 'user'), 'user'); + * // => ['barney', 'fred', 'pebbles'] */ function sortBy(collection, iteratee, thisArg) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = null; } + iteratee = getCallback(iteratee, thisArg, 3); + var index = -1, length = collection ? collection.length : 0, - multi = iteratee && isArray(iteratee), - result = []; + result = isLength(length) ? Array(length) : []; - if (isLength(length)) { - result.length = length; - } - if (!multi) { - iteratee = getCallback(iteratee, thisArg, 3); - } baseEach(collection, function(value, key, collection) { - if (multi) { - var length = iteratee.length, - criteria = Array(length); + result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value }; + }); + return baseSortBy(result, compareAscending); + } - while (length--) { - criteria[length] = value == null ? undefined : value[iteratee[length]]; - } - } else { - criteria = iteratee(value, key, collection); + /** + * This method is like `_.sortBy` except that it sorts by property names + * instead of an iteratee function. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(string|string[])} props The property names to sort by, + * specified as individual property names or arrays of property names. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 26 }, + * { 'user': 'fred', 'age': 30 } + * ]; + * + * _.map(_.sortByAll(users, ['user', 'age']), _.values); + * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + */ + function sortByAll(collection) { + var args = arguments; + if (args.length == 4 && isIterateeCall(args[1], args[2], args[3])) { + args = [collection, args[1]]; + } + var index = -1, + length = collection ? collection.length : 0, + props = baseFlatten(args, false, false, 1), + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value, key, collection) { + var length = props.length, + criteria = Array(length); + + while (length--) { + criteria[length] = value == null ? undefined : value[props[length]]; } result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); - - length = result.length; - result.sort(multi ? compareMultipleAscending : compareAscending); - while (length--) { - result[length] = result[length].value; - } - return result; + return baseSortBy(result, compareMultipleAscending); } /** @@ -6387,7 +6459,10 @@ * // => [1, 2, 3] */ function curry(func, arity, guard) { - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, guard ? null : arity); + if (guard && isIterateeCall(func, arity, guard)) { + arity = null; + } + var result = createWrapper(func, CURRY_FLAG, null, null, null, null, arity); result.placeholder = curry.placeholder; return result; } @@ -6421,6 +6496,9 @@ * // => [1, 2, 3] */ function curryRight(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = null; + } var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, guard ? null : arity); result.placeholder = curryRight.placeholder; return result; @@ -6650,9 +6728,9 @@ } /** - * Creates a function that invokes the provided functions with the `this` - * binding of the created function, where each successive invocation is - * supplied the return value of the previous. + * Creates a function that returns the result of invoking the provided + * functions with the `this` binding of the created function, where each + * successive invocation is supplied the return value of the previous. * * @static * @memberOf _ @@ -6850,8 +6928,8 @@ /** * Creates a function that invokes `func` with `partial` arguments prepended - * to those provided to the new function. This method is similar to `_.bind` - * except it does **not** alter the `this` binding. + * to those provided to the new function. This method is like `_.bind` except + * it does **not** alter the `this` binding. * * **Note:** This method does not set the `length` property of partially * applied functions. @@ -6880,8 +6958,8 @@ * This method is like `_.partial` except that partially applied arguments * are appended to those provided to the new function. * - * **Note:** This method does not set the `length` property of partially applied - * functions. + * **Note:** This method does not set the `length` property of partially + * applied functions. * * @static * @memberOf _ @@ -6924,7 +7002,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} [indexes] The arranged argument indexes, + * @param {...(number|number[])} indexes The arranged argument indexes, * specified as individual indexes or arrays of indexes. * @returns {Function} Returns the new function. * @example @@ -7057,8 +7135,8 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * var shallow = _.clone(users); @@ -7080,7 +7158,7 @@ * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - // juggle arguments + // Juggle arguments. if (typeof isDeep != 'boolean' && isDeep != null) { thisArg = customizer; customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; @@ -7113,8 +7191,8 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * var deep = _.cloneDeep(users); @@ -7158,7 +7236,7 @@ var length = (value && typeof value == 'object') ? value.length : undefined; return (isLength(length) && toString.call(value) == argsClass) || false; } - // fallback for environments without a `[[Class]]` for `arguments` objects + // Fallback for environments without a `[[Class]]` for `arguments` objects. if (!support.argsClass) { isArguments = function(value) { var length = (value && typeof value == 'object') ? value.length : undefined; @@ -7249,7 +7327,7 @@ return (value && typeof value == 'object' && value.nodeType === 1 && (lodash.support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isHostObject(value))) || false; } - // fallback for environments without DOM support + // Fallback for environments without DOM support. if (!support.dom) { isElement = function(value) { return (value && typeof value == 'object' && value.nodeType === 1 && !isPlainObject(value)) || false; @@ -7412,17 +7490,17 @@ * // => false */ function isFunction(value) { - // Use `|| false` to avoid a Chakra bug in compatibility modes of IE 11. + // Avoid a Chakra JIT bug in compatibility modes of IE 11. // See https://github.com/jashkenas/underscore/issues/1621. return typeof value == 'function' || false; } - // fallback for environments that return incorrect `typeof` operator results - if (isFunction(/x/) || !Uint8Array || !isFunction(Uint8Array)) { + // Fallback for environments that return incorrect `typeof` operator results. + if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { isFunction = function(value) { - // the use of `Object#toString` avoids issues with the `typeof` operator + // The use of `Object#toString` avoids issues with the `typeof` operator // in older versions of Chrome and Safari which return 'function' for - // regexes and modern Safari which returns 'object' for typed array - // constructors + // regexes and Safari 8 equivalents which return 'object' for typed + // array constructors. return toString.call(value) == funcClass; }; } @@ -7450,7 +7528,7 @@ * // => false */ function isObject(value) { - // Avoid a V8 bug in Chrome 19-20. + // Avoid a V8 JIT bug in Chrome 19-20. // See https://code.google.com/p/v8/issues/detail?id=2291. var type = typeof value; return type == 'function' || (value && type == 'object') || false; @@ -7484,7 +7562,7 @@ */ function isNaN(value) { // `NaN` as a primitive is the only value that is not equal to itself - // (perform the `[[Class]]` check first to avoid errors with some host objects in IE) + // (perform the `[[Class]]` check first to avoid errors with some host objects in IE). return isNumber(value) && value != +value; } @@ -7732,7 +7810,9 @@ */ function create(prototype, properties, guard) { var result = baseCreate(prototype); - properties = guard ? null : properties; + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = null; + } return properties ? baseAssign(result, properties) : result; } @@ -8030,8 +8110,9 @@ * // => { 'fred': ['first', 'third'], 'barney': ['second'] } */ function invert(object, multiValue, guard) { - multiValue = guard ? null : multiValue; - + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = null; + } var index = -1, props = keys(object), length = props.length, @@ -8137,7 +8218,7 @@ // Lo-Dash skips the `constructor` property when it infers it is iterating // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]` // attribute of an existing property and the `constructor` property of a - // prototype defaults to non-enumerable + // prototype defaults to non-enumerable. for (var key in object) { if (!(skipProto && key == 'prototype') && !(skipErrorProps && (key == 'message' || key == 'name')) && @@ -8153,9 +8234,9 @@ if (className == objectClass) { proto = objectProto; } - length = shadowedProps.length; + length = shadowProps.length; while (length--) { - key = shadowedProps[length]; + key = shadowProps[length]; var nonEnum = nonEnums[key]; if (!(isProto && nonEnum) && (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) { @@ -8567,6 +8648,17 @@ * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't require escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. + * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can break out + * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. + * * When working with HTML you should always quote attribute values to reduce * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping) * for more details. @@ -8582,7 +8674,7 @@ * // => 'fred, barney, & pebbles' */ function escape(string) { - // reset `lastIndex` because in IE < 9 `String#replace` does not + // Reset `lastIndex` because in IE < 9 `String#replace` does not. string = string == null ? '' : String(string); return string && (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) @@ -8759,8 +8851,8 @@ } string = String(string); - // leverage the exponentiation by squaring algorithm for a faster repeat - // http://en.wikipedia.org/wiki/Exponentiation_by_squaring + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See http://en.wikipedia.org/wiki/Exponentiation_by_squaring. do { if (n % 2) { result += string; @@ -8920,10 +9012,8 @@ * '); */ function template(string, options, otherOptions) { - // based on John Resig's `tmpl` implementation - // http://ejohn.org/blog/javascript-micro-templating/ - // and Laura Doktorova's doT.js - // https://github.com/olado/doT + // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/) + // and Laura Doktorova's doT.js (https://github.com/olado/doT). var settings = lodash.templateSettings; if (otherOptions && isIterateeCall(string, options, otherOptions)) { @@ -8942,7 +9032,7 @@ interpolate = options.interpolate || reNoMatch, source = "__p += '"; - // compile the regexp to match each delimiter + // Compile the regexp to match each delimiter. var reDelimiters = RegExp( (options.escape || reNoMatch).source + '|' + interpolate.source + '|' + @@ -8950,18 +9040,18 @@ (options.evaluate || reNoMatch).source + '|$' , 'g'); - // use a sourceURL for easier debugging - // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + // Use a sourceURL for easier debugging. + // See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl. var sourceURL = 'sourceURL' in options ? options.sourceURL : ('/lodash/template/source[' + (++templateCounter) + ']'); - sourceURL = sourceURL ? ('\n//# sourceURL=' + sourceURL) : ''; + sourceURL = sourceURL ? ('//# sourceURL=' + sourceURL + '\n') : ''; string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); - // escape characters that can't be included in string literals + // Escape characters that can't be included in string literals. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); - // replace delimiters with snippets + // Replace delimiters with snippets. if (escapeValue) { isEscaping = true; source += "' +\n__e(" + escapeValue + ") +\n'"; @@ -8975,25 +9065,25 @@ } index = offset + match.length; - // the JS engine embedded in Adobe products requires returning the `match` - // string in order to produce the correct `offset` value + // The JS engine embedded in Adobe products requires returning the `match` + // string in order to produce the correct `offset` value. return match; }); source += "';\n"; - // if `variable` is not specified, wrap a with-statement around the generated - // code to add the data object to the top of the scope chain + // If `variable` is not specified, wrap a with-statement around the generated + // code to add the data object to the top of the scope chain. var variable = options.variable; if (!variable) { source = 'with (obj) {\n' + source + '\n}\n'; } - // cleanup code by stripping empty strings + // Cleanup code by stripping empty strings. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) .replace(reEmptyStringMiddle, '$1') .replace(reEmptyStringTrailing, '$1;'); - // frame code as the function body + // Frame code as the function body. source = 'function(' + (variable || 'obj') + ') {\n' + (variable ? '' @@ -9013,11 +9103,11 @@ 'return __p\n}'; var result = attempt(function() { - return Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues); + return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues); }); - // provide the compiled function's source by its `toString` method or - // the `source` property as a convenience for inlining compiled templates + // Provide the compiled function's source by its `toString` method or + // the `source` property as a convenience for inlining compiled templates. result.source = source; if (isError(result)) { throw result; @@ -9048,7 +9138,7 @@ if (!string) { return string; } - if (guard || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -9073,12 +9163,12 @@ * _.trimLeft('-_-fred-_-', '_-'); * // => 'fred-_-' */ - function trimLeft(string, chars, guards) { + function trimLeft(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (guards || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -9108,7 +9198,7 @@ if (!string) { return string; } - if (guard || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -9148,8 +9238,9 @@ * // => 'hi-diddly-ho there, neig [...]' */ function trunc(string, options, guard) { - options = guard ? null : options; - + if (guard && isIterateeCall(string, options, guard)) { + options = null; + } var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; @@ -9242,7 +9333,9 @@ */ function words(string, pattern, guard) { string = string != null && String(string); - pattern = guard ? null : pattern; + if (guard && isIterateeCall(string, pattern, guard)) { + pattern = null; + } return (string && string.match(pattern || reWords)) || []; } @@ -9308,11 +9401,14 @@ * }; * }); * - * _.filter(users, 'age__gt38'); + * _.filter(users, 'age__gt36'); * // => [{ 'user': 'fred', 'age': 40 }] */ function callback(func, thisArg, guard) { - return baseCallback(func, guard ? undefined : thisArg); + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = null; + } + return baseCallback(func, thisArg); } /** @@ -9497,8 +9593,8 @@ var chainAll = this.__chain__; if (chain || chainAll) { var result = object(this.__wrapped__); + (result.__actions__ = baseSlice(this.__actions__)).push({ 'args': arguments, 'object': object, 'name': methodName }); result.__chain__ = chainAll; - (result.__queue__ = baseSlice(this.__queue__)).push({ 'args': arguments, 'object': object, 'name': methodName }); return result; } var args = [this.value()]; @@ -9541,7 +9637,7 @@ * // => true */ function noop() { - // no operation performed + // No operation performed. } /** @@ -9581,16 +9677,19 @@ * // => 8 */ function parseInt(value, radix, guard) { - return nativeParseInt(value, guard ? 0 : radix); + if (guard && isIterateeCall(value, radix, guard)) { + radix = 0; + } + return nativeParseInt(value, radix); } - // fallback for environments with pre-ES5 implementations + // Fallback for environments with pre-ES5 implementations. if (nativeParseInt(whitespace + '08') != 8) { parseInt = function(value, radix, guard) { // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and // Chrome fails to trim leading whitespace characters. // See https://code.google.com/p/v8/issues/detail?id=3109. value = trim(value); - radix = guard ? 0 : +radix; + radix = (guard && isIterateeCall(value, radix, guard)) ? 0 : +radix; return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10)); }; } @@ -9607,8 +9706,8 @@ * @example * * var users = [ - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } + * { 'user': 'fred' }, + * { 'user': 'barney' } * ]; * * var getName = _.property('user'); @@ -9758,8 +9857,8 @@ } else { end = +end || 0; } - // use `Array(length)` so engines like Chakra and V8 avoid slower modes - // http://youtu.be/XAqIpGU8ZZk#t=17m25s + // Use `Array(length)` so engines like Chakra and V8 avoid slower modes. + // See http://youtu.be/XAqIpGU8ZZk#t=17m25s. var index = -1, length = nativeMax(ceil((end - start) / (step || 1)), 0), result = Array(length); @@ -9836,7 +9935,13 @@ * // => also invokes `mage.castSpell(n)` three times */ function times(n, iteratee, thisArg) { - n = nativeIsFinite(n = +n) && n > -1 ? n : 0; + n = +n; + + // Exit early to avoid a JSC JIT bug in Safari 8 + // where `Array(0)` is treated as `Array(1)`. + if (n < 1 || !nativeIsFinite(n)) { + return []; + } iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, @@ -9875,21 +9980,22 @@ /*------------------------------------------------------------------------*/ - // ensure `new LodashWrapper` is an instance of `lodash` + // Ensure `new LodashWrapper` is an instance of `lodash`. LodashWrapper.prototype = lodash.prototype; - // add functions to the `Map` cache + // Add functions to the `Map` cache. + MapCache.prototype['delete'] = mapDelete; MapCache.prototype.get = mapGet; MapCache.prototype.has = mapHas; MapCache.prototype.set = mapSet; - // add functions to the `Set` cache + // Add functions to the `Set` cache. SetCache.prototype.push = cachePush; - // assign cache to `_.memoize` + // Assign cache to `_.memoize`. memoize.Cache = MapCache; - // add functions that return wrapped values when chaining + // Add functions that return wrapped values when chaining. lodash.after = after; lodash.assign = assign; lodash.at = at; @@ -9962,6 +10068,7 @@ lodash.shuffle = shuffle; lodash.slice = slice; lodash.sortBy = sortBy; + lodash.sortByAll = sortByAll; lodash.take = take; lodash.takeRight = takeRight; lodash.takeRightWhile = takeRightWhile; @@ -9984,7 +10091,7 @@ lodash.zip = zip; lodash.zipObject = zipObject; - // add aliases + // Add aliases. lodash.backflow = flowRight; lodash.collect = map; lodash.compose = flowRight; @@ -9998,18 +10105,17 @@ lodash.tail = rest; lodash.unique = uniq; - // add functions to `lodash.prototype` + // Add functions to `lodash.prototype`. mixin(lodash, lodash); /*------------------------------------------------------------------------*/ - // add functions that return unwrapped values when chaining + // Add functions that return unwrapped values when chaining. lodash.attempt = attempt; lodash.camelCase = camelCase; lodash.capitalize = capitalize; lodash.clone = clone; lodash.cloneDeep = cloneDeep; - lodash.contains = contains; lodash.deburr = deburr; lodash.endsWith = endsWith; lodash.escape = escape; @@ -10025,6 +10131,7 @@ lodash.first = first; lodash.has = has; lodash.identity = identity; + lodash.includes = includes; lodash.indexOf = indexOf; lodash.isArguments = isArguments; lodash.isArray = isArray; @@ -10078,14 +10185,15 @@ lodash.uniqueId = uniqueId; lodash.words = words; - // add aliases + // Add aliases. lodash.all = every; lodash.any = some; + lodash.contains = includes; lodash.detect = find; lodash.foldl = reduce; lodash.foldr = reduceRight; lodash.head = first; - lodash.include = contains; + lodash.include = includes; lodash.inject = reduce; mixin(lodash, (function() { @@ -10100,11 +10208,10 @@ /*------------------------------------------------------------------------*/ - // add functions capable of returning wrapped and unwrapped values when chaining + // Add functions capable of returning wrapped and unwrapped values when chaining. lodash.sample = sample; - lodash.prototype.sample = function(n, guard) { - n = guard ? null : n; + lodash.prototype.sample = function(n) { if (!this.__chain__ && n == null) { return lodash.sample(this.value()); } @@ -10124,14 +10231,14 @@ */ lodash.VERSION = VERSION; - // assign default placeholders + // Assign default placeholders. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { lodash[methodName].placeholder = lodash; }); - // add `LazyWrapper` methods that accept an `iteratee` value + // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var isFilter = !index; + var isFilter = index == LAZY_FILTER_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); @@ -10140,13 +10247,13 @@ filtered = result.filtered, iteratees = result.iteratees || (result.iteratees = []); - result.filtered = filtered || index == LAZY_FILTER_FLAG || (index == LAZY_WHILE_FLAG && result.dir < 0); + result.filtered = filtered || isFilter || (index == LAZY_WHILE_FLAG && result.dir < 0); iteratees.push({ 'iteratee': iteratee, 'type': index }); return result; }; }); - // add `LazyWrapper` methods for `_.drop` and `_.take` variants + // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. arrayEach(['drop', 'take'], function(methodName, index) { var countName = methodName + 'Count', whileName = methodName + 'While'; @@ -10174,7 +10281,7 @@ }; }); - // add `LazyWrapper` methods for `_.first` and `_.last` + // Add `LazyWrapper` methods for `_.first` and `_.last`. arrayEach(['first', 'last'], function(methodName, index) { var takeName = 'take' + (index ? 'Right': ''); @@ -10183,7 +10290,7 @@ }; }); - // add `LazyWrapper` methods for `_.initial` and `_.rest` + // Add `LazyWrapper` methods for `_.initial` and `_.rest`. arrayEach(['initial', 'rest'], function(methodName, index) { var dropName = 'drop' + (index ? '' : 'Right'); @@ -10192,6 +10299,16 @@ }; }); + // Add `LazyWrapper` methods for `_.pluck` and `_.where`. + arrayEach(['pluck', 'where'], function(methodName, index) { + var operationName = index ? 'filter' : 'map', + createCallback = index ? matches : property; + + LazyWrapper.prototype[methodName] = function(value) { + return this[operationName](createCallback(value)); + }; + }); + LazyWrapper.prototype.dropWhile = function(iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); @@ -10225,42 +10342,51 @@ return result; }; - // add `LazyWrapper` methods to `lodash.prototype` + // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var args = arguments, + var value = this.__wrapped__, + args = arguments, chainAll = this.__chain__, - value = this.__wrapped__, - isLazy = value instanceof LazyWrapper; + isHybrid = !!this.__actions__.length, + isLazy = value instanceof LazyWrapper, + onlyLazy = isLazy && !isHybrid; if (retUnwrapped && !chainAll) { - return isLazy + return onlyLazy ? func.call(value) : lodash[methodName](this.value()); } - if (isLazy || isArray(value)) { - var result = func.apply(isLazy ? value : new LazyWrapper(this), args); - return new LodashWrapper(result, chainAll); - } - return this.thru(function(value) { + var interceptor = function(value) { var otherArgs = [value]; push.apply(otherArgs, args); return lodash[methodName].apply(lodash, otherArgs); - }); + }; + if (isLazy || isArray(value)) { + var wrapper = onlyLazy ? value : new LazyWrapper(this), + result = func.apply(wrapper, args); + + if (!retUnwrapped && (isHybrid || result.actions)) { + var actions = result.actions || (result.actions = []); + actions.push({ 'args': [interceptor], 'object': lodash, 'name': 'thru' }); + } + return new LodashWrapper(result, chainAll); + } + return this.thru(interceptor); }; }); - // add `Array.prototype` functions to `lodash.prototype` + // Add `Array.prototype` functions to `lodash.prototype`. arrayEach(['concat', 'join', 'pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var arrayFunc = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', fixObjects = !support.spliceObjects && /^(?:pop|shift|splice)$/.test(methodName), retUnwrapped = /^(?:join|pop|shift)$/.test(methodName); - // avoid array-like object bugs with `Array#shift` and `Array#splice` in - // IE < 9, Firefox < 10, Narwhal, and RingoJS + // Avoid array-like object bugs with `Array#shift` and `Array#splice` in + // IE < 9, Firefox < 10, Narwhal, and RingoJS. var func = !fixObjects ? arrayFunc : function() { var result = arrayFunc.apply(this, arguments); if (this.length === 0) { @@ -10280,18 +10406,18 @@ }; }); - // add functions to the lazy wrapper + // Add functions to the lazy wrapper. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // add chaining functions to the lodash wrapper + // Add chaining functions to the lodash wrapper. lodash.prototype.chain = wrapperChain; lodash.prototype.reverse = wrapperReverse; lodash.prototype.toString = wrapperToString; - lodash.prototype.toJSON = lodash.prototype.value = lodash.prototype.valueOf = wrapperValueOf; + lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - // add function aliases to the lodash wrapper + // Add function aliases to the lodash wrapper. lodash.prototype.collect = lodash.prototype.map; lodash.prototype.head = lodash.prototype.first; lodash.prototype.select = lodash.prototype.filter; @@ -10302,35 +10428,35 @@ /*--------------------------------------------------------------------------*/ - // export Lo-Dash + // Export Lo-Dash. var _ = runInContext(); - // some AMD build optimizers like r.js check for condition patterns like the following: + // Some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { // Expose Lo-Dash to the global object when an AMD loader is present to avoid // errors in cases where Lo-Dash is loaded by a script tag and not intended - // as an AMD module. See http://requirejs.org/docs/errors.html#mismatch + // as an AMD module. See http://requirejs.org/docs/errors.html#mismatch. root._ = _; - // define as an anonymous module so, through path mapping, it can be - // referenced as the "underscore" module + // Define as an anonymous module so, through path mapping, it can be + // referenced as the "underscore" module. define(function() { return _; }); } - // check for `exports` after `define` in case a build optimizer adds an `exports` object + // Check for `exports` after `define` in case a build optimizer adds an `exports` object. else if (freeExports && freeModule) { - // in Node.js or RingoJS + // Export for Node.js or RingoJS. if (moduleExports) { (freeModule.exports = _)._ = _; } - // in Narwhal or Rhino -require + // Export for Narwhal or Rhino -require. else { freeExports._ = _; } } else { - // in a browser or Rhino + // Export for a browser or Rhino. root._ = _; } }.call(this)); diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 1e9d2f22a..ee0b1d24c 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,81 +4,83 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n) -}function w(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Kt(n){for(var t=-1,r=n.length,e=Hu;++tu(t,i)&&a.push(i);return a}function rr(n,t){var r=n?n.length:0;if(!Mr(r))return sr(n,t);for(var e=-1,u=Hr(n);++ec))return false}else{var g=p&&ju.call(n,"__wrapped__"),h=h&&ju.call(t,"__wrapped__");if(g||h)return gr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!a&&!p){switch(l){case yt:case dt:return+n==+t;case bt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case xt:case jt:return n==vu(t)}return false}if(Lt.support.argsClass||(c=Ue(n),i=Ue(t)),g=c?hu:n.constructor,l=i?hu:t.constructor,a){if(g.prototype.name!=l.prototype.name)return false}else if(p=!c&&ju.call(n,"constructor"),h=!i&&ju.call(t,"constructor"),p!=h||!p&&g!=l&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof l=="function"&&l instanceof l))return false; -if(g=a?["message","name"]:wo(n),l=a?g:wo(t),c&&g.push("length"),i&&l.push("length"),c=g.length,p=l.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;if(u.push(n),o.push(t),i=true,f)for(;i&&++le(a,s)&&((t||i)&&a.push(s),l.push(c))}return l}function jr(n,t){for(var r=-1,e=t(n),u=e.length,o=au(u);++rt||null==r)return r; -if(3t?0:t)}function ne(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),oe(n,0,0>t?0:t)}function te(n,t,r){var e=-1,u=n?n.length:0;for(t=Lr(t,r,3);++er?Ku(e+r,0):r||0;else if(r)return r=ie(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return f(n,t,r)}function ue(n){return Qr(n,1) -}function oe(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&Dr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=au(u);++er?Ku(e+r,0):r||0:0,typeof n=="string"||!yo(n)&&De(n)?ri||r===Xu&&r===a)&&(i=r,a=n)}),a}function be(n,t){return me(n,iu(t))}function we(n,t,r,e){return(yo(n)?u:_r)(n,Lr(t,e,4),r,3>arguments.length,rr)}function xe(n,t,r,e){return(yo(n)?o:_r)(n,Lr(t,e,4),r,3>arguments.length,er)}function je(n){n=Xr(n);for(var t=-1,r=n.length,e=au(r);++t=r||r>t?(a&&Ru(a),r=p,a=s=p=I,r&&(h=Io(),f=n.apply(c,i),s||a||(i=c=null))):s=Wu(e,r)}function u(){s&&Ru(s),a=s=p=I,(v||g!==t)&&(h=Io(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=Io(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{a||y||(h=l);var o=g-(l-h),d=0>=o||o>g;d?(a&&(a=Ru(a)),h=l,f=n.apply(c,i)):a||(a=Wu(u,o))}return d&&s?s=Ru(s):s||t===g||(s=Wu(e,t)),r&&(d=true,f=n.apply(c,i)),!d||s||a||(i=c=null),f -}var i,a,f,l,c,s,p,h=0,g=false,v=true;if(!$e(n))throw new yu(D);if(t=0>t?0:t,true===r)var y=true,v=false;else qe(r)&&(y=r.leading,g="maxWait"in r&&Ku(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Ru(s),a&&Ru(a),a=s=p=I},o}function Se(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,$e))throw new yu(D);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Fe(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0]; -if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(!$e(n)||t&&!$e(t))throw new yu(D);return r.cache=new Fe.Cache,r}function Te(n){var t=oe(arguments,1),r=w(t,Te.placeholder);return Wr(n,T,null,t,r)}function Ne(n){var t=oe(arguments,1),r=w(t,Ne.placeholder);return Wr(n,N,null,t,r)}function Ue(n){return Mr(n&&typeof n=="object"?n.length:I)&&Eu.call(n)==gt||false}function We(n){return n&&typeof n=="object"&&1===n.nodeType&&(Lt.support.nodeClass?-1t||null==n||!Du(t))return r;n=vu(n);do t%2&&(r+=n),t=Su(t/2),n+=n;while(t);return r}function Je(n,t,r){return(n=null==n?"":vu(n))?r||null==t?n.slice(x(n),j(n)+1):(t=vu(t),n.slice(s(n,t),p(n,t)+1)):n -}function Xe(n,t,r){return(n=null!=n&&vu(n))&&n.match((r?null:t)||ct)||[]}function He(n){try{return n()}catch(t){return Le(t)?t:lu(t)}}function Qe(n,t,r){return Ht(n,r?I:t)}function nu(n){return function(){return n}}function tu(n){return n}function ru(n){var t=wo(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Kr(u))return function(n){return null!=n&&u===n[e]&&ju.call(n,e)}}for(var o=r,i=au(r),a=au(r);o--;){var u=n[t[o]],f=Kr(u);i[o]=f?u:Qt(u,true,Er),a[o]=f}return function(n){if(o=r,null==n)return!o;for(;o--;)if(a[o]?i[o]!==n[t[o]]:!ju.call(n,t[o]))return false; -for(o=r;o--;)if(a[o]?!ju.call(n,t[o]):!gr(i[o],n[t[o]],null,true))return false;return true}}function eu(n,t,r){var e=true,u=qe(t),o=null==r,i=o&&u&&wo(t),a=i&&hr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=hr(t,wo(t))),false===r?e=false:qe(r)&&"chain"in r&&(e=r.chain),r=-1,u=$e(n);for(o=a.length;++r=$)return r}else n=0;return ao(r,e)}}(),so=Cr(function(n,t,r){ju.call(n,r)?++n[r]:n[r]=1}),po=Cr(function(n,t,r){ju.call(n,r)?n[r].push(t):n[r]=[t]}),ho=Cr(function(n,t,r){n[r]=t}),go=Cr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]] -}),vo=Wr(Ee,T,null,[2]);io.argsClass||(Ue=function(n){return Mr(n&&typeof n=="object"?n.length:I)&&ju.call(n,"callee")&&!Nu.call(n,"callee")||false});var yo=Bu||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Eu.call(n)==vt||false};io.dom||(We=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!_o(n)||false});var mo=Zu||function(n){return typeof n=="number"&&Du(n)};!$e(/x/)&&$u&&$e($u)||($e=function(n){return Eu.call(n)==_t});var _o=Fu?function(n){if(!n||Eu.call(n)!=wt||!Lt.support.argsClass&&Ue(n))return false; -var t=n.valueOf,r=Pe(t)&&(r=Fu(t))&&Fu(r);return r?n==r||Fu(n)==r:Gr(n)}:Gr,bo=kr(Jt),wo=Mu?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},Lt.assign=bo,Lt.at=function(n){return(!n||Mr(n.length))&&(n=Xr(n)),Xt(n,ar(arguments,false,false,1))},Lt.before=Ee,Lt.bind=Ie,Lt.bindAll=function(n){for(var t=n,r=1(s?Dt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Dt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i) -}return c},Lt.invert=function(n,t,r){t=r?null:t,r=-1;for(var e=wo(n),u=e.length,o={};++rt?0:t)},Lt.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),oe(n,0>t?0:t)},Lt.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Lr(t,r,3);e--&&t(n[e],e,n););return oe(n,e+1)},Lt.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Lr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Lt.escape=function(n){return(n=null==n?"":vu(n))&&(J.lastIndex=0,J.test(n))?n.replace(J,y):n},Lt.escapeRegExp=Ze,Lt.every=he,Lt.find=ve,Lt.findIndex=te,Lt.findKey=function(n,t,r){return t=Lr(t,r,3),ir(n,t,sr,true)},Lt.findLast=function(n,t,r){return t=Lr(t,r,3),ir(n,t,er) -},Lt.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Lr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Lt.findLastKey=function(n,t,r){return t=Lr(t,r,3),ir(n,t,pr,true)},Lt.findWhere=function(n,t){return ve(n,ru(t))},Lt.first=re,Lt.has=function(n,t){return n?ju.call(n,t):false},Lt.identity=tu,Lt.indexOf=ee,Lt.isArguments=Ue,Lt.isArray=yo,Lt.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Eu.call(n)==yt||false},Lt.isDate=function(n){return n&&typeof n=="object"&&Eu.call(n)==dt||false -},Lt.isElement=We,Lt.isEmpty=function(n){if(null==n)return true;var t=n.length;return Mr(t)&&(yo(n)||De(n)||Ue(n)||typeof n=="object"&&$e(n.splice))?!t:!wo(n).length},Lt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Ht(r,e,3),!r&&Kr(n)&&Kr(t)?n===t:gr(n,t,r)},Lt.isError=Le,Lt.isFinite=mo,Lt.isFunction=$e,Lt.isNaN=function(n){return ze(n)&&n!=+n},Lt.isNative=Pe,Lt.isNull=function(n){return null===n},Lt.isNumber=ze,Lt.isObject=qe,Lt.isPlainObject=_o,Lt.isRegExp=Be,Lt.isString=De,Lt.isUndefined=function(n){return typeof n=="undefined" -},Lt.kebabCase=Ao,Lt.last=function(n){var t=n?n.length:0;return t?n[t-1]:I},Lt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Ku(e+r,0):Vu(r||0,e-1))+1;else if(r)return u=ae(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return m(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Lt.max=_e,Lt.min=function(n,t,r){r&&Dr(n,t,r)&&(t=null);var e=null==t,u=e&&yo(n),o=!u&&De(n);if(e&&!o)return Kt(u?n:Xr(n));var i=Hu,a=i;return t=e&&o?c:Lr(t,r,3),rr(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Lt.template=function(n,t,r){var e=Lt.templateSettings;r&&Dr(n,t,r)&&(t=r=null),n=vu(null==n?"":n),t=bo({},r||t,e,Gt),r=bo({},t.imports,e.imports,Gt); -var u,o,i=wo(r),a=Ve(r),f=0;r=t.interpolate||it;var l="__p+='";if(r=gu((t.escape||it).source+"|"+r.source+"|"+(r===Q?nt:it).source+"|"+(t.evaluate||it).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(lt,d),r&&(u=true,l+="'+__e("+r+")+'"),a&&(o=true,l+="';"+a+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),f=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(V,""):l).replace(Y,"$1").replace(Z,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=He(function(){return cu(i,"return "+l).apply(I,a) -}),t.source=l,Le(t))throw t;return t},Lt.trim=Je,Lt.trimLeft=function(n,t,r){return(n=null==n?"":vu(n))?r||null==t?n.slice(x(n)):(t=vu(t),n.slice(s(n,t))):n},Lt.trimRight=function(n,t,r){return(n=null==n?"":vu(n))?r||null==t?n.slice(0,j(n)+1):(t=vu(t),n.slice(0,p(n,t)+1)):n},Lt.trunc=function(n,t,r){t=r?null:t;var e=W;if(r=L,qe(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?vu(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":vu(n),e>=n.length)return n; -if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(Be(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=gu(u.source,(tt.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Lt.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Lt.sample(t,n)}):Lt.sample(this.value())},Lt.VERSION=O,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Lt[n].placeholder=Lt}),n(["filter","map","takeWhile"],function(n,t){qt.prototype[n]=function(n,r){n=Lr(n,r,3); -var e=this.clone(),u=e.filtered,o=e.iteratees||(e.iteratees=[]);return e.filtered=u||t==P||t==B&&0>e.dir,o.push({iteratee:n,type:t}),e}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";qt.prototype[n]=function(e){e=null==e?1:Ku(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Vu(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},qt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},qt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse() -}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");qt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");qt.prototype[n]=function(){return this[r](1)}}),qt.prototype.dropWhile=function(n,t){n=Lr(n,t,3);var r,e,u=0>this.dir;return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},qt.prototype.reject=function(n,t){return n=Lr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},qt.prototype.slice=function(n,t){n=null==n?0:+n||0; -var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},sr(qt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Lt.prototype[t]=function(){var e=arguments,u=this.__chain__,o=this.__wrapped__,i=o instanceof qt;return r&&!u?i?n.call(o):Lt[t](this.value()):i||yo(o)?(o=n.apply(i?o:new qt(this),e),new $t(o,u)):this.thru(function(n){return n=[n],Tu.apply(n,e),Lt[t].apply(Lt,n)})}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=du[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n),u=io.spliceObjects||!/^(?:pop|shift|splice)$/.test(n)?t:function(){var n=t.apply(this,arguments); -return 0===this.length&&delete this[0],n};Lt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?u.apply(this.value(),n):this[r](function(t){return u.apply(t,n)})}}),qt.prototype.clone=function(){var n=this.iteratees,t=this.views,r=new qt(this.wrapped);return r.dir=this.dir,r.dropCount=this.dropCount,r.filtered=this.filtered,r.iteratees=n?l(n):null,r.takeCount=this.takeCount,r.views=t?l(t):null,r},qt.prototype.reverse=function(){var n=this.filtered,t=n?new qt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t -},qt.prototype.value=function(){var n,t=this.wrapped.value(),r=this.dir,e=0>r,u=t.length;n=u;for(var o=this.views,i=0,a=-1,f=o?o.length:0;++a"'`]/g,X=/<%-([\s\S]+?)%>/g,H=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,nt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tt=/\w*$/,rt=/^\s*function[ \n\r\t]+\w/,et=/^0[xX]/,ut=/^\[object .+?Constructor\]$/,ot=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,it=/($^)/,at=/[.*+?^${}()|[\]\/\\]/g,ft=/\bthis\b/,lt=/['\n\r\u2028\u2029\\]/g,ct=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),st=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",pt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),ht="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt="[object Arguments]",vt="[object Array]",yt="[object Boolean]",dt="[object Date]",mt="[object Error]",_t="[object Function]",bt="[object Number]",wt="[object Object]",xt="[object RegExp]",jt="[object String]",At="[object ArrayBuffer]",Et="[object Float32Array]",It="[object Float64Array]",Ot="[object Int8Array]",Ct="[object Int16Array]",kt="[object Int32Array]",Rt="[object Uint8Array]",St="[object Uint8ClampedArray]",Ft="[object Uint16Array]",Tt="[object Uint32Array]",Nt={}; -Nt[gt]=Nt[vt]=Nt[Et]=Nt[It]=Nt[Ot]=Nt[Ct]=Nt[kt]=Nt[Rt]=Nt[St]=Nt[Ft]=Nt[Tt]=true,Nt[At]=Nt[yt]=Nt[dt]=Nt[mt]=Nt[_t]=Nt["[object Map]"]=Nt[bt]=Nt[wt]=Nt[xt]=Nt["[object Set]"]=Nt[jt]=Nt["[object WeakMap]"]=false;var Ut={};Ut[gt]=Ut[vt]=Ut[At]=Ut[yt]=Ut[dt]=Ut[Et]=Ut[It]=Ut[Ot]=Ut[Ct]=Ut[kt]=Ut[bt]=Ut[wt]=Ut[xt]=Ut[jt]=Ut[Rt]=Ut[St]=Ut[Ft]=Ut[Tt]=true,Ut[mt]=Ut[_t]=Ut["[object Map]"]=Ut["[object Set]"]=Ut["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Lt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},$t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Pt={"function":true,object:true},zt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Pt[typeof window]&&window!==(this&&this.window)?window:this,Dt=Pt[typeof exports]&&exports&&!exports.nodeType&&exports,Mt=Pt[typeof module]&&module&&!module.nodeType&&module,Kt=Dt&&Mt&&typeof global=="object"&&global; -!Kt||Kt.global!==Kt&&Kt.window!==Kt&&Kt.self!==Kt||(Bt=Kt);var Vt=Mt&&Mt.exports===Dt&&Dt,Yt=function(){try{String({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Zt=E();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Zt, define(function(){return Zt})):Dt&&Mt?Vt?(Mt.exports=Zt)._=Zt:Dt._=Zt:Bt._=Zt}).call(this); \ No newline at end of file +return r}function i(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function x(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Vt(n){for(var t=-1,r=n.length,e=no;++to(t,a)&&e.push(a);return e}function er(n,t){var r=n?n.length:0;if(!Vr(r))return pr(n,t);for(var e=-1,u=ne(n);++ec))return false}else{var g=p&&Eu.call(n,"__wrapped__"),h=h&&Eu.call(t,"__wrapped__");if(g||h)return vr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!a&&!p){switch(l){case dt:case mt:return+n==+t;case wt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case jt:case At:return n==du(t)}return false}if($t.support.argsClass||(c=Le(n),i=Le(t)),g=c?vu:n.constructor,l=i?vu:t.constructor,a){if(g.prototype.name!=l.prototype.name)return false +}else if(p=!c&&Eu.call(n,"constructor"),h=!i&&Eu.call(t,"constructor"),p!=h||!p&&g!=l&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof l=="function"&&l instanceof l))return false;if(g=a?["message","name"]:jo(n),l=a?g:jo(t),c&&g.push("length"),i&&l.push("length"),c=g.length,p=l.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;if(u.push(n),o.push(t),i=true,f)for(;i&&++le(a,s)&&((t||i)&&a.push(s),l.push(c))}return l}function Ar(n,t){for(var r=-1,e=t(n),u=e.length,o=lu(u);++rt||null==r)return r;if(3t?0:t)}function re(n,t,r){return(r?Kr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ae(n,0,0>t?0:t)}function ee(n,t,r){var e=-1,u=n?n.length:0;for(t=Pr(t,r,3);++er?Yu(e+r,0):r||0;else if(r)return r=fe(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return f(n,t,r)}function ie(n){return te(n,1)}function ae(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&Kr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=lu(u);++er?Yu(e+r,0):r||0:0,typeof n=="string"||!_o(n)&&Ke(n)?ri||r===Qu&&r===a)&&(i=r,a=n) +}),a}function xe(n,t){return be(n,fu(t))}function je(n,t,r,e){return(_o(n)?u:br)(n,Pr(t,e,4),r,3>arguments.length,er)}function Ae(n,t,r,e){return(_o(n)?o:br)(n,Pr(t,e,4),r,3>arguments.length,ur)}function Ee(n){n=Qr(n);for(var t=-1,r=n.length,e=lu(r);++t=r||r>t?(a&&Fu(a),r=p,a=s=p=O,r&&(h=Co(),f=n.apply(c,i),s||a||(i=c=null))):s=$u(e,r)}function u(){s&&Fu(s),a=s=p=O,(v||g!==t)&&(h=Co(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=Co(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{a||y||(h=l);var o=g-(l-h),d=0>=o||o>g;d?(a&&(a=Fu(a)),h=l,f=n.apply(c,i)):a||(a=$u(u,o))}return d&&s?s=Fu(s):s||t===g||(s=$u(e,t)),r&&(d=true,f=n.apply(c,i)),!d||s||a||(i=c=null),f}var i,a,f,l,c,s,p,h=0,g=false,v=true;if(!Be(n))throw new mu(q);if(t=0>t?0:t,true===r)var y=true,v=false; +else ze(r)&&(y=r.leading,g="maxWait"in r&&Yu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Fu(s),a&&Fu(a),a=s=p=O},o}function Te(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Be))throw new mu(q);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Ne(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o +}if(!Be(n)||t&&!Be(t))throw new mu(q);return r.cache=new Ne.Cache,r}function Ue(n){var t=ae(arguments,1),r=x(t,Ue.placeholder);return $r(n,N,null,t,r)}function We(n){var t=ae(arguments,1),r=x(t,We.placeholder);return $r(n,U,null,t,r)}function Le(n){return Vr(n&&typeof n=="object"?n.length:O)&&Ou.call(n)==vt||false}function $e(n){return n&&typeof n=="object"&&1===n.nodeType&&($t.support.nodeClass?-1t||null==n||!Ku(t))return r;n=du(n);do t%2&&(r+=n),t=Tu(t/2),n+=n;while(t);return r}function He(n,t,r){return(n=null==n?"":du(n))?(r?Kr(n,t,r):null==t)?n.slice(j(n),A(n)+1):(t=du(t),n.slice(p(n,t),h(n,t)+1)):n}function Qe(n,t,r){return n=null!=n&&du(n),r&&Kr(n,t,r)&&(t=null),n&&n.match(t||st)||[] +}function nu(n){try{return n()}catch(t){return Pe(t)?t:su(t)}}function tu(n,t,r){return r&&Kr(n,t,r)&&(t=null),Qt(n,t)}function ru(n){return function(){return n}}function eu(n){return n}function uu(n){var t=jo(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Yr(u))return function(n){return null!=n&&u===n[e]&&Eu.call(n,e)}}for(var o=r,i=lu(r),a=lu(r);o--;){var u=n[t[o]],f=Yr(u);i[o]=f?u:nr(u,true,Or),a[o]=f}return function(n){if(o=r,null==n)return!o;for(;o--;)if(a[o]?i[o]!==n[t[o]]:!Eu.call(n,t[o]))return false; +for(o=r;o--;)if(a[o]?!Eu.call(n,t[o]):!vr(i[o],n[t[o]],null,true))return false;return true}}function ou(n,t,r){var e=true,u=ze(t),o=null==r,i=o&&u&&jo(t),a=i&&gr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=gr(t,jo(t))),false===r?e=false:ze(r)&&"chain"in r&&(e=r.chain),r=-1,u=Be(n);for(o=a.length;++r=P)return r}else n=0;return lo(r,e)}}(),ho=Rr(function(n,t,r){Eu.call(n,r)?++n[r]:n[r]=1}),go=Rr(function(n,t,r){Eu.call(n,r)?n[r].push(t):n[r]=[t]}),vo=Rr(function(n,t,r){n[r]=t}),yo=Rr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]] +}),mo=$r(Oe,N,null,[2]);fo.argsClass||(Le=function(n){return Vr(n&&typeof n=="object"?n.length:O)&&Eu.call(n,"callee")&&!Wu.call(n,"callee")||false});var _o=qu||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ou.call(n)==yt||false};fo.dom||($e=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!wo(n)||false});var bo=Ju||function(n){return typeof n=="number"&&Ku(n)};(Be(/x/)||Bu&&!Be(Bu))&&(Be=function(n){return Ou.call(n)==bt});var wo=Nu?function(n){if(!n||Ou.call(n)!=xt||!$t.support.argsClass&&Le(n))return false; +var t=n.valueOf,r=De(t)&&(r=Nu(t))&&Nu(r);return r?n==r||Nu(n)==r:Xr(n)}:Xr,xo=Sr(Xt),jo=Vu?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},$t.assign=xo,$t.at=function(n){return(!n||Vr(n.length))&&(n=Qr(n)),Ht(n,fr(arguments,false,false,1))},$t.before=Oe,$t.bind=Ce,$t.bindAll=function(n){for(var t=n,r=1(s?qt(s,i):u(c,i))){for(t=r;--t;){var p=e[t]; +if(0>(p?qt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i)}return c},$t.invert=function(n,t,r){r&&Kr(n,t,r)&&(t=null),r=-1;for(var e=jo(n),u=e.length,o={};++rt?0:t)},$t.takeRight=function(n,t,r){return(r?Kr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ae(n,0>t?0:t) +},$t.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Pr(t,r,3);e--&&t(n[e],e,n););return ae(n,e+1)},$t.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Pr(t,r,3);++en||!Ku(n))return[];t=Qt(t,r,1),r=-1;for(var e=lu(Zu(n,to));++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},$t.escape=function(n){return(n=null==n?"":du(n))&&(X.lastIndex=0,X.test(n))?n.replace(X,d):n},$t.escapeRegExp=Je,$t.every=ve,$t.find=de,$t.findIndex=ee,$t.findKey=function(n,t,r){return t=Pr(t,r,3),ar(n,t,pr,true) +},$t.findLast=function(n,t,r){return t=Pr(t,r,3),ar(n,t,ur)},$t.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Pr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},$t.findLastKey=function(n,t,r){return t=Pr(t,r,3),ar(n,t,hr,true)},$t.findWhere=function(n,t){return de(n,uu(t))},$t.first=ue,$t.has=function(n,t){return n?Eu.call(n,t):false},$t.identity=eu,$t.includes=ge,$t.indexOf=oe,$t.isArguments=Le,$t.isArray=_o,$t.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Ou.call(n)==dt||false +},$t.isDate=function(n){return n&&typeof n=="object"&&Ou.call(n)==mt||false},$t.isElement=$e,$t.isEmpty=function(n){if(null==n)return true;var t=n.length;return Vr(t)&&(_o(n)||Ke(n)||Le(n)||typeof n=="object"&&Be(n.splice))?!t:!jo(n).length},$t.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Qt(r,e,3),!r&&Yr(n)&&Yr(t)?n===t:vr(n,t,r)},$t.isError=Pe,$t.isFinite=bo,$t.isFunction=Be,$t.isNaN=function(n){return Me(n)&&n!=+n},$t.isNative=De,$t.isNull=function(n){return null===n},$t.isNumber=Me,$t.isObject=ze,$t.isPlainObject=wo,$t.isRegExp=qe,$t.isString=Ke,$t.isUndefined=function(n){return typeof n=="undefined" +},$t.kebabCase=Io,$t.last=function(n){var t=n?n.length:0;return t?n[t-1]:O},$t.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Yu(e+r,0):Zu(r||0,e-1))+1;else if(r)return u=le(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},$t.max=we,$t.min=function(n,t,r){r&&Kr(n,t,r)&&(t=null);var e=null==t,u=e&&_o(n),o=!u&&Ke(n);if(e&&!o)return Vt(u?n:Qr(n));var i=no,a=i;return t=e&&o?s:Pr(t,r,3),er(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},$t.template=function(n,t,r){var e=$t.templateSettings;r&&Kr(n,t,r)&&(t=r=null),n=du(null==n?"":n),t=xo({},r||t,e,Jt),r=xo({},t.imports,e.imports,Jt); +var u,o,i=jo(r),a=Ze(r),f=0;r=t.interpolate||at;var l="__p+='";if(r=yu((t.escape||at).source+"|"+r.source+"|"+(r===nt?tt:at).source+"|"+(t.evaluate||at).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(ct,m),r&&(u=true,l+="'+__e("+r+")+'"),a&&(o=true,l+="';"+a+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),f=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(Y,""):l).replace(Z,"$1").replace(G,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=nu(function(){return pu(i,"return "+l).apply(O,a) +}),t.source=l,Pe(t))throw t;return t},$t.trim=He,$t.trimLeft=function(n,t,r){return(n=null==n?"":du(n))?(r?Kr(n,t,r):null==t)?n.slice(j(n)):(t=du(t),n.slice(p(n,t))):n},$t.trimRight=function(n,t,r){return(n=null==n?"":du(n))?(r?Kr(n,t,r):null==t)?n.slice(0,A(n)+1):(t=du(t),n.slice(0,h(n,t)+1)):n},$t.trunc=function(n,t,r){r&&Kr(n,t,r)&&(t=null);var e=L;if(r=$,ze(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?du(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":du(n),e>=n.length)return n; +if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(qe(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=yu(u.source,(rt.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},$t.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return $t.sample(t,n)}):$t.sample(this.value())},$t.VERSION=C,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){$t[n].placeholder=$t}),n(["filter","map","takeWhile"],function(n,t){var r=t==z; +Bt.prototype[n]=function(n,e){n=Pr(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==M&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";Bt.prototype[n]=function(e){e=null==e?1:Yu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Zu(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},Bt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse() +},Bt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");Bt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Bt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?uu:fu;Bt.prototype[n]=function(n){return this[r](e(n))}}),Bt.prototype.dropWhile=function(n,t){n=Pr(n,t,3);var r,e,u=0>this.dir; +return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},Bt.prototype.reject=function(n,t){return n=Pr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Bt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},pr(Bt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);$t.prototype[t]=function(){function e(n){return n=[n],Uu.apply(n,o),$t[t].apply($t,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,a=!!this.__actions__.length,f=u instanceof Bt,l=f&&!a; +return r&&!i?l?n.call(u):$t[t](this.value()):f||_o(u)?(u=n.apply(l?u:new Bt(this),o),r||!a&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:$t,name:"thru"}),new Pt(u,i)):this.thru(e)}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=_u[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n),u=fo.spliceObjects||!/^(?:pop|shift|splice)$/.test(n)?t:function(){var n=t.apply(this,arguments);return 0===this.length&&delete this[0],n +};$t.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?u.apply(this.value(),n):this[r](function(t){return u.apply(t,n)})}}),Bt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new Bt(this.wrapped);return e.actions=n?l(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?l(t):null,e.takeCount=this.takeCount,e.views=r?l(r):null,e},Bt.prototype.reverse=function(){var n=this.filtered,t=n?new Bt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t +},Bt.prototype.value=function(){var n=this.wrapped.value();if(!_o(n))return Er(n,this.actions);var t,r=this.dir,e=0>r,u=n.length;t=u;for(var o=this.views,i=0,a=-1,f=o?o.length:0;++a"'`]/g,H=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,nt=/<%=([\s\S]+?)%>/g,tt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,et=/^\s*function[ \n\r\t]+\w/,ut=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,it=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ft=/[.*+?^${}()|[\]\/\\]/g,lt=/\bthis\b/,ct=/['\n\r\u2028\u2029\\]/g,st=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),pt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",ht="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),gt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),vt="[object Arguments]",yt="[object Array]",dt="[object Boolean]",mt="[object Date]",_t="[object Error]",bt="[object Function]",wt="[object Number]",xt="[object Object]",jt="[object RegExp]",At="[object String]",Et="[object ArrayBuffer]",It="[object Float32Array]",Ot="[object Float64Array]",Ct="[object Int8Array]",kt="[object Int16Array]",Rt="[object Int32Array]",St="[object Uint8Array]",Ft="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Nt="[object Uint32Array]",Ut={}; +Ut[vt]=Ut[yt]=Ut[It]=Ut[Ot]=Ut[Ct]=Ut[kt]=Ut[Rt]=Ut[St]=Ut[Ft]=Ut[Tt]=Ut[Nt]=true,Ut[Et]=Ut[dt]=Ut[mt]=Ut[_t]=Ut[bt]=Ut["[object Map]"]=Ut[wt]=Ut[xt]=Ut[jt]=Ut["[object Set]"]=Ut[At]=Ut["[object WeakMap]"]=false;var Wt={};Wt[vt]=Wt[yt]=Wt[Et]=Wt[dt]=Wt[mt]=Wt[It]=Wt[Ot]=Wt[Ct]=Wt[kt]=Wt[Rt]=Wt[wt]=Wt[xt]=Wt[jt]=Wt[At]=Wt[St]=Wt[Ft]=Wt[Tt]=Wt[Nt]=true,Wt[_t]=Wt[bt]=Wt["[object Map]"]=Wt["[object Set]"]=Wt["[object WeakMap]"]=false;var Lt={leading:false,maxWait:0,trailing:false},$t={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Pt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Bt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},zt={"function":true,object:true},Dt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mt=zt[typeof window]&&window!==(this&&this.window)?window:this,qt=zt[typeof exports]&&exports&&!exports.nodeType&&exports,Kt=zt[typeof module]&&module&&!module.nodeType&&module,Vt=qt&&Kt&&typeof global=="object"&&global; +!Vt||Vt.global!==Vt&&Vt.window!==Vt&&Vt.self!==Vt||(Mt=Vt);var Yt=Kt&&Kt.exports===qt&&qt,Zt=function(){try{String({toString:0}+"")}catch(n){return function(){return false}}return function(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}}(),Gt=I();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Mt._=Gt, define(function(){return Gt})):qt&&Kt?Yt?(Kt.exports=Gt)._=Gt:qt._=Gt:Mt._=Gt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 3fba184eb..fe5666ba3 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -9,13 +9,13 @@ */ ;(function() { - /** Used as a safe reference for `undefined` in pre ES5 environments */ + /** Used as a safe reference for `undefined` in pre ES5 environments. */ var undefined; - /** Used as the semantic version number */ + /** Used as the semantic version number. */ var VERSION = '3.0.0-pre'; - /** Used to compose bitmasks for wrapper metadata */ + /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_FLAG = 4, @@ -25,38 +25,38 @@ PARTIAL_RIGHT_FLAG = 64, REARG_FLAG = 128; - /** Used as default options for `_.trunc` */ + /** Used as default options for `_.trunc`. */ var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = '...'; - /** Used to detect when a function becomes hot */ + /** Used to detect when a function becomes hot. */ var HOT_COUNT = 150, HOT_SPAN = 16; - /** Used to indicate the type of lazy iteratees */ + /** Used to indicate the type of lazy iteratees. */ var LAZY_FILTER_FLAG = 0, LAZY_MAP_FLAG = 1, LAZY_WHILE_FLAG = 2; - /** Used as the `TypeError` message for "Functions" methods */ + /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; - /** Used as the internal argument placeholder */ + /** Used as the internal argument placeholder. */ var PLACEHOLDER = '__lodash_placeholder__'; - /** Used to generate unique IDs */ + /** Used to generate unique IDs. */ var idCounter = 0; - /** Used to match empty string literals in compiled template source */ + /** Used to match empty string literals in compiled template source. */ var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - /** Used to match HTML entities and HTML characters */ + /** Used to match HTML entities and HTML characters. */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g, reUnescapedHtml = /[&<>"'`]/g; - /** Used to match template delimiters */ + /** Used to match template delimiters. */ var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g; @@ -68,22 +68,22 @@ */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - /** Used to match `RegExp` flags from their coerced string values */ + /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; - /** Used to detect named functions */ + /** Used to detect named functions. */ var reFuncName = /^\s*function[ \n\r\t]+\w/; - /** Used to detect hexadecimal string values */ + /** Used to detect hexadecimal string values. */ var reHexPrefix = /^0[xX]/; - /** Used to detect host constructors (Safari > 5) */ + /** Used to detect host constructors (Safari > 5). */ var reHostCtor = /^\[object .+?Constructor\]$/; - /** Used to match latin-1 supplement letters (excluding mathematical operators) */ + /** Used to match latin-1 supplement letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; - /** Used to ensure capturing order of template delimiters */ + /** Used to ensure capturing order of template delimiters. */ var reNoMatch = /($^)/; /** @@ -93,13 +93,13 @@ */ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g; - /** Used to detect functions containing a `this` reference */ + /** Used to detect functions containing a `this` reference. */ var reThis = /\bthis\b/; - /** Used to match unescaped characters in compiled string literals */ + /** Used to match unescaped characters in compiled string literals. */ var reUnescapedString = /['\n\r\u2028\u2029\\]/g; - /** Used to match words to create compound words */ + /** Used to match words to create compound words. */ var reWords = (function() { var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; @@ -107,19 +107,19 @@ return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); - /** Used to detect and test whitespace */ + /** Used to detect and test for whitespace. */ var whitespace = ( - // whitespace + // Basic whitespace characters. ' \t\x0b\f\xa0\ufeff' + - // line terminators + // Line terminators. '\n\r\u2028\u2029' + - // unicode category "Zs" space separators + // Unicode category "Zs" space separators. '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); - /** Used to assign default `context` object properties */ + /** Used to assign default `context` object properties. */ var contextProps = [ 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', @@ -129,10 +129,10 @@ 'window', 'WinRTError' ]; - /** Used to make template sourceURLs easier to identify */ + /** Used to make template sourceURLs easier to identify. */ var templateCounter = -1; - /** `Object#toString` result references */ + /** `Object#toString` result references. */ var argsClass = '[object Arguments]', arrayClass = '[object Array]', boolClass = '[object Boolean]', @@ -158,7 +158,7 @@ uint16Class = '[object Uint16Array]', uint32Class = '[object Uint32Array]'; - /** Used to identify object classifications that are treated like arrays */ + /** Used to identify object classifications that are treated like arrays. */ var arrayLikeClasses = {}; arrayLikeClasses[argsClass] = arrayLikeClasses[arrayClass] = arrayLikeClasses[float32Class] = @@ -173,7 +173,7 @@ arrayLikeClasses[regexpClass] = arrayLikeClasses[setClass] = arrayLikeClasses[stringClass] = arrayLikeClasses[weakMapClass] = false; - /** Used to identify object classifications that `_.clone` supports */ + /** Used to identify object classifications that `_.clone` supports. */ var cloneableClasses = {}; cloneableClasses[argsClass] = cloneableClasses[arrayClass] = cloneableClasses[arrayBufferClass] = cloneableClasses[boolClass] = @@ -188,14 +188,14 @@ cloneableClasses[funcClass] = cloneableClasses[mapClass] = cloneableClasses[setClass] = cloneableClasses[weakMapClass] = false; - /** Used as an internal `_.debounce` options object by `_.throttle` */ + /** Used as an internal `_.debounce` options object by `_.throttle`. */ var debounceOptions = { 'leading': false, 'maxWait': 0, 'trailing': false }; - /** Used to map latin-1 supplementary letters to basic latin letters */ + /** Used to map latin-1 supplementary letters to basic latin letters. */ var deburredLetters = { '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', @@ -216,20 +216,7 @@ '\xdf': 'ss' }; - /** - * Used to map characters to HTML entities. - * - * **Note:** Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't require escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. - * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * Backticks are escaped because in Internet Explorer < 9, they can break out - * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), - * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of - * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. - */ + /** Used to map characters to HTML entities. */ var htmlEscapes = { '&': '&', '<': '<', @@ -239,7 +226,7 @@ '`': '`' }; - /** Used to map HTML entities to characters */ + /** Used to map HTML entities to characters. */ var htmlUnescapes = { '&': '&', '<': '<', @@ -249,13 +236,13 @@ '`': '`' }; - /** Used to determine if values are of the language type `Object` */ + /** Used to determine if values are of the language type `Object`. */ var objectTypes = { 'function': true, 'object': true }; - /** Used to escape characters for inclusion in compiled string literals */ + /** Used to escape characters for inclusion in compiled string literals. */ var stringEscapes = { '\\': '\\', "'": "'", @@ -273,19 +260,19 @@ */ var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; - /** Detect free variable `exports` */ + /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - /** Detect free variable `module` */ + /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { root = freeGlobal; } - /** Detect the popular CommonJS extension `module.exports` */ + /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /*--------------------------------------------------------------------------*/ @@ -536,6 +523,26 @@ return result; } + /** + * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` + * to define the sort order of `array` and replaces criteria objects with their + * corresponding values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + /** * Used by `_.max` and `_.min` as the default callback for string values. * @@ -581,7 +588,7 @@ } /** - * Used by `_.sortBy` to compare transformed elements of `collection` and stable + * Used by `_.sortBy` to compare transformed elements of a collection and stable * sort them in ascending order. * * @private @@ -594,8 +601,8 @@ } /** - * Used by `_.sortBy` to compare multiple properties of each element in a - * collection and stable sort them in ascending order. + * Used by `_.sortByAll` to compare multiple properties of each element + * in a collection and stable sort them in ascending order. * * @private * @param {Object} object The object to compare to `other`. @@ -616,7 +623,7 @@ } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications // that causes it, under certain circumstances, to provide the same value - // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247. // // This also ensures a stable sort in V8 and other engines. // See https://code.google.com/p/v8/issues/detail?id=90. @@ -836,7 +843,7 @@ // See http://es5.github.io/#x11.1.5. context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - /** Native constructor references */ + /** Native constructor references. */ var Array = context.Array, Date = context.Date, Error = context.Error, @@ -848,32 +855,32 @@ String = context.String, TypeError = context.TypeError; - /** Used for native method references */ + /** Used for native method references. */ var arrayProto = Array.prototype, objectProto = Object.prototype; - /** Used to detect DOM support */ + /** Used to detect DOM support. */ var document = (document = context.window) && document.document; - /** Used to resolve the decompiled source of functions */ + /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; - /** Used to check objects for own properties */ + /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; - /** Used to restore the original `_` reference in `_.noConflict` */ + /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = context._; - /** Used to resolve the internal `[[Class]]` of values */ + /** Used to resolve the internal `[[Class]]` of values. */ var toString = objectProto.toString; - /** Used to detect if a method is native */ + /** Used to detect if a method is native. */ var reNative = RegExp('^' + escapeRegExp(toString) .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); - /** Native method references */ + /** Native method references. */ var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, ceil = Math.ceil, @@ -889,11 +896,11 @@ unshift = arrayProto.unshift, WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; - /** Used to clone array buffers */ + /** Used to clone array buffers. */ var Float64Array = (function() { // Safari 5 errors when using an array buffer to initialize a typed array // where the array buffer's `byteLength` is not a multiple of the typed - // array's `BYTES_PER_ELEMENT` + // array's `BYTES_PER_ELEMENT`. try { var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func; @@ -901,7 +908,7 @@ return result; }()); - /* Native method references for those with the same name as other `lodash` methods */ + /* Native method references for those with the same name as other `lodash` methods. */ var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, @@ -913,15 +920,15 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used as references for `-Infinity` and `Infinity` */ + /** Used as references for `-Infinity` and `Infinity`. */ var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY, POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - /** Used as references for the max length and index of an array */ + /** Used as references for the max length and index of an array. */ var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - /** Used as the size, in bytes, of each Float64Array element */ + /** Used as the size, in bytes, of each Float64Array element. */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; /** @@ -931,7 +938,7 @@ */ var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - /** Used to store function metadata */ + /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; /*------------------------------------------------------------------------*/ @@ -958,22 +965,22 @@ * `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`, * `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, * `rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, - * `sortBy`, `splice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, - * `tap`, `throttle`, `thru`, `times`, `toArray`, `transform`, `union`, `uniq`, - * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, - * `zip`, and `zipObject` + * `sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `transform`, + * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, + * `without`, `wrap`, `xor`, `zip`, and `zipObject` * * The non-chainable wrapper functions are: - * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `contains`, - * `deburr`, endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, - * `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, isDate`, - * `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, `isFunction`, - * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, - * `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, `last`, - * `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, `padRight`, - * `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, - * `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, + * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, + * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, + * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, + * `isFunction`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `kebabCase`, + * `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, + * `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, + * `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, * `sortedLastIndex`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, * `trunc`, `unescape`, `uniqueId`, `value`, and `words` * @@ -1008,7 +1015,7 @@ return value; } if (hasOwnProperty.call(value, '__wrapped__')) { - return new LodashWrapper(value.__wrapped__, value.__chain__, baseSlice(value.__queue__)); + return new LodashWrapper(value.__wrapped__, value.__chain__, baseSlice(value.__actions__)); } } return new LodashWrapper(value); @@ -1020,11 +1027,11 @@ * @private * @param {*} value The value to wrap. * @param {boolean} [chainAll=false] Enable chaining for all wrapper methods. - * @param {Array} [queue=[]] Actions to peform to resolve the unwrapped value. + * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. */ - function LodashWrapper(value, chainAll, queue) { + function LodashWrapper(value, chainAll, actions) { + this.__actions__ = actions || []; this.__chain__ = !!chainAll; - this.__queue__ = queue || []; this.__wrapped__ = value; } @@ -1089,8 +1096,8 @@ }(0, 0)); /** - * By default, the template delimiters used by Lo-Dash are similar to those - * in embedded Ruby (ERB). Change the following template settings to use + * By default, the template delimiters used by Lo-Dash are like those in + * embedded Ruby (ERB). Change the following template settings to use * alternative delimiters. * * @static @@ -1158,6 +1165,7 @@ * @param {*} value The value to wrap. */ function LazyWrapper(value) { + this.actions = null; this.dir = 1; this.dropCount = 0; this.filtered = false; @@ -1176,10 +1184,12 @@ * @returns {Object} Returns the cloned `LazyWrapper` object. */ function lazyClone() { - var iteratees = this.iteratees, + var actions = this.actions, + iteratees = this.iteratees, views = this.views, result = new LazyWrapper(this.wrapped); + result.actions = actions ? baseSlice(actions) : null; result.dir = this.dir; result.dropCount = this.dropCount; result.filtered = this.filtered; @@ -1215,8 +1225,11 @@ * @returns {*} Returns the unwrapped value. */ function lazyValue() { - var array = this.wrapped.value(), - dir = this.dir, + var array = this.wrapped.value(); + if (!isArray(array)) { + return baseWrapperValue(array, this.actions); + } + var dir = this.dir, isRight = dir < 0, length = array.length, view = getView(0, length, this.views), @@ -1276,6 +1289,19 @@ this.__data__ = {}; } + /** + * Removes `key` and its value from the cache. + * + * @private + * @name delete + * @memberOf _.memoize.Cache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`. + */ + function mapDelete(key) { + return this.has(key) && delete this.__data__[key]; + } + /** * Gets the cached value for `key`. * @@ -1286,7 +1312,7 @@ * @returns {*} Returns the cached value. */ function mapGet(key) { - return this.__data__[key]; + return key == '__proto__' ? undefined : this.__data__[key]; } /** @@ -1521,8 +1547,7 @@ } /** - * The base implementation of `_.callback` without support for creating - * "_.pluck" and "_.where" style callbacks. + * The base implementation of `_.callback`. * * @private * @param {*} [func=_.identity] The value to convert to a callback. @@ -1550,13 +1575,13 @@ data = !reFuncName.test(source); } if (!data) { - // checks if `func` references the `this` keyword and stores the result + // Check if `func` references the `this` keyword and store the result. data = reThis.test(source) || isNative(func); baseSetData(func, data); } } } - // exit early if there are no `this` references or `func` is bound + // Exit early if there are no `this` references or `func` is bound. if (data === false || (data !== true && data[1] & BIND_FLAG)) { return func; } @@ -1581,7 +1606,7 @@ if (func == null) { return identity; } - // handle "_.pluck" and "_.where" style callback shorthands + // Handle "_.pluck" and "_.where" style callback shorthands. return type == 'object' ? matches(func) : property(func); } @@ -1623,7 +1648,7 @@ if (!isDeep || result === value) { return result; } - // check for circular references and return corresponding clone + // Check for circular references and return corresponding clone. stackA || (stackA = []); stackB || (stackB = []); @@ -1633,12 +1658,11 @@ return stackB[length]; } } - // add the source value to the stack of traversed objects - // and associate it with its clone + // Add the source value to the stack of traversed objects and associate it with its clone. stackA.push(value); stackB.push(result); - // recursively populate clone (susceptible to call stack limits) + // Recursively populate clone (susceptible to call stack limits). (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); }); @@ -1656,7 +1680,7 @@ function baseCreate(prototype) { return isObject(prototype) ? nativeCreate(prototype) : {}; } - // fallback for environments without `Object.create` + // Fallback for environments without `Object.create`. if (!nativeCreate) { baseCreate = (function() { function Object() {} @@ -1681,15 +1705,16 @@ * @returns {Array} Returns the new array of filtered values. */ function baseDifference(array, values) { - var length = array ? array.length : 0; + var length = array ? array.length : 0, + result = []; + if (!length) { - return []; + return result; } var index = -1, indexOf = getIndexOf(), isCommon = indexOf == baseIndexOf, cache = isCommon && values.length >= 200 && createCache(values), - result = [], valuesLength = values.length; if (cache) { @@ -1852,7 +1877,7 @@ if (value && typeof value == 'object' && typeof value.length == 'number' && (isArray(value) || isArguments(value))) { - // recursively flatten arrays (susceptible to call stack limits) + // Recursively flatten arrays (susceptible to call stack limits). if (isDeep) { value = baseFlatten(value, isDeep, isStrict); } @@ -1998,19 +2023,19 @@ * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, customizer, isWhere, stackA, stackB) { - var result = customizer && !stackA ? customizer(value, other) : undefined; + var result = (customizer && !stackA) ? customizer(value, other) : undefined; if (typeof result != 'undefined') { return !!result; } - // exit early for identical values + // Exit early for identical values. if (value === other) { - // treat `+0` vs. `-0` as not equal + // Treat `+0` vs. `-0` as not equal. return value !== 0 || (1 / value == 1 / other); } var valType = typeof value, othType = typeof other; - // exit early for unlike primitive values + // Exit early for unlike primitive values. if (!(valType == 'number' && othType == 'number') && (value == null || other == null || (valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object'))) { return false; @@ -2041,7 +2066,7 @@ } } else { - // unwrap any `lodash` wrapped values + // Unwrap `lodash` wrapped values. var valWrapped = valIsObj && hasOwnProperty.call(value, '__wrapped__'), othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); @@ -2052,12 +2077,12 @@ return false; } if (valIsErr || valIsObj) { - // in older versions of Opera, `arguments` objects have `Array` constructors + // In older versions of Opera, `arguments` objects have `Array` constructors. var valCtor = valIsArg ? Object : value.constructor, othCtor = othIsArg ? Object : other.constructor; if (valIsErr) { - // error objects of different types are not equal + // Error objects of different types are not equal. if (valCtor.prototype.name != othCtor.prototype.name) { return false; } @@ -2070,7 +2095,7 @@ return false; } if (!valHasCtor) { - // non `Object` object instances with different constructors are not equal + // Non `Object` object instances with different constructors are not equal. if (valCtor != othCtor && ('constructor' in value && 'constructor' in other) && !(typeof valCtor == 'function' && valCtor instanceof valCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { @@ -2097,29 +2122,29 @@ switch (valClass) { case boolClass: case dateClass: - // coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. return +value == +other; case numberClass: - // treat `NaN` vs. `NaN` as equal + // Treat `NaN` vs. `NaN` as equal. return (value != +value) ? other != +other - // but treat `-0` vs. `+0` as not equal + // But, treat `-0` vs. `+0` as not equal. : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); case regexpClass: case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and - // treat strings primitives and string objects as equal + // Coerce regexes to strings (http://es5.github.io/#x15.10.6.4) and + // treat strings primitives and string objects as equal. return value == String(other); } return false; } } - // assume cyclic structures are equal - // the algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) + // Assume cyclic structures are equal. + // The algorithm for detecting cyclic structures is adapted from ES 5.1 + // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3). stackA || (stackA = []); stackB || (stackB = []); @@ -2129,14 +2154,14 @@ return stackB[index] == other; } } - // add `value` and `other` to the stack of traversed objects + // Add `value` and `other` to the stack of traversed objects. stackA.push(value); stackB.push(other); - // recursively compare objects and arrays (susceptible to call stack limits) + // Recursively compare objects and arrays (susceptible to call stack limits). result = true; if (valIsArr) { - // deep compare the contents, ignoring non-numeric properties + // Deep compare the contents, ignoring non-numeric properties. while (result && ++index < valLength) { var valValue = value[index]; if (isWhere) { @@ -2192,11 +2217,8 @@ var index = -1, isFunc = typeof methodName == 'function', length = collection ? collection.length : 0, - result = []; + result = isLength(length) ? Array(length) : []; - if (isLength(length)) { - result.length = length; - } baseEach(collection, function(value) { var func = isFunc ? methodName : (value != null && value[methodName]); result[++index] = func ? func.apply(value, args) : undefined; @@ -2252,7 +2274,7 @@ } return; } - // avoid merging previously merged cyclic sources + // Avoid merging previously merged cyclic sources. stackA || (stackA = []); stackB || (stackB = []); @@ -2271,12 +2293,12 @@ ? (isArray(value) ? value : []) : (isPlainObject(value) ? value : {}); } - // add the source value to the stack of traversed objects - // and associate it with its merged value + // Add the source value to the stack of traversed objects and associate + // it with its merged value. stackA.push(srcValue); stackB.push(result); - // recursively merge objects and arrays (susceptible to call stack limits) + // Recursively merge objects and arrays (susceptible to call stack limits). if (isDeep) { baseMerge(result, srcValue, customizer, stackA, stackB); } @@ -2325,7 +2347,7 @@ /** * The base implementation of `_.reduce` and `_.reduceRight` without support * for callback shorthands or `this` binding, which iterates over `collection` - * usingthe provided `eachFunc`. + * using the provided `eachFunc`. * * @private * @param {Array|Object|string} collection The collection to iterate over. @@ -2495,6 +2517,35 @@ return result; } + /** + * The base implementation of `wrapperValue` which returns the result of + * performing a sequence of actions on the unwrapped `value`, where each + * successive action is supplied the return value of the previous. + * + * @private + * @param {*} value The unwrapped value. + * @param {Array} actions Actions to peform to resolve the unwrapped value. + * @returns {*} Returns the resolved unwrapped value. + */ + function baseWrapperValue(value, actions) { + var result = value; + if (result instanceof LazyWrapper) { + result = result.value(); + } + var index = -1, + length = actions.length; + + while (++index < length) { + var args = [result], + action = actions[index], + object = action.object; + + push.apply(args, action.args); + result = object[action.name].apply(object, args); + } + return result; + } + /** * Creates a clone of the given array buffer. * @@ -2506,8 +2557,8 @@ return bufferSlice.call(buffer, 0); } if (!bufferSlice) { - // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` - bufferClone = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`. + bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) { var byteLength = buffer.byteLength, floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, @@ -2652,7 +2703,7 @@ if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { length = 2; } - // juggle arguments + // Juggle arguments. if (length > 3 && typeof arguments[length - 2] == 'function') { var customizer = baseCallback(arguments[--length - 1], arguments[length--], 5); } else if (length > 2 && typeof arguments[length - 1] == 'function') { @@ -2730,8 +2781,8 @@ var thisBinding = baseCreate(Ctor.prototype), result = Ctor.apply(thisBinding, arguments); - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 + // Mimic the constructor's `return` behavior. + // See http://es5.github.io/#x13.2.2. return isObject(result) ? result : thisBinding; }; } @@ -2763,6 +2814,8 @@ key = func; function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it to other functions. var length = arguments.length, index = length, args = Array(length); @@ -2837,23 +2890,23 @@ /** * Creates a function that wraps `func` and invokes it with the optional `this` - * binding of `thisArg` and the `partialArgs` prepended to those provided to + * binding of `thisArg` and the `partials` prepended to those provided to * the wrapper. * * @private * @param {Function} func The function to partially apply arguments to. * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} thisArg The `this` binding of `func`. * @param {Array} partials The arguments to prepend to those provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. * @returns {Function} Returns the new bound function. */ - function createPartialWrapper(func, bitmask, partials, thisArg) { + function createPartialWrapper(func, bitmask, thisArg, partials) { var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { - // avoid `arguments` object use disqualifying optimizations by - // converting it to an array before providing it to `composeArgs` + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it `func`. var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, @@ -2889,7 +2942,7 @@ * 128 - `_.rearg` * @param {*} [thisArg] The `this` binding of `func`. * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partialArgs` placeholder indexes. + * @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [argPos] The argument positions of the new function. * @param {number} [arity] The arity of `func`. * @returns {Function} Returns the new wrapped function. @@ -2904,83 +2957,35 @@ bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); partials = holders = null; } - if (partials && !holders) { - holders = []; - } - var oldPartials = partials, - oldHolders = holders, - isPartial = bitmask & PARTIAL_FLAG, - isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; + holders = (partials && !holders) ? [] : holders; + length -= (holders ? holders.length : 0); - if (!isPartial) { + if (bitmask & PARTIAL_RIGHT_FLAG) { var partialsRight = partials, holdersRight = holders; partials = holders = null; } - var data = (data = !isBindKey && getData(func)) && data !== true && data; - if (data) { - var funcBitmask = data[1], - funcIsBind = funcBitmask & BIND_FLAG, - isBind = bitmask & BIND_FLAG; + var data = !isBindKey && getData(func), + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity]; - // use metadata `func` and merge bitmasks - func = data[0]; - bitmask |= funcBitmask; + if (data && data !== true && !(argPos && (data[3] || data[5]))) { + newData = mergeData(newData, data); + } + newData[8] = newData[8] == null + ? (isBindKey ? 0 : newData[0].length) + : nativeMax(newData[8] - length, 0) || 0; - // use metadata `thisArg` if available - if (funcIsBind) { - thisArg = data[2]; - } - // set if currying a bound function - if (!isBind && funcIsBind) { - bitmask |= CURRY_BOUND_FLAG; - } - // compose partial arguments - var value = data[3]; - if (value) { - var funcHolders = data[4]; - partials = isPartial ? composeArgs(partials, value, funcHolders) : baseSlice(value); - holders = isPartial ? replaceHolders(partials, PLACEHOLDER) : baseSlice(funcHolders); - } - // compose partial right arguments - value = data[5]; - if (value) { - funcHolders = data[6]; - partialsRight = isPartialRight ? composeArgsRight(partialsRight, value, funcHolders) : baseSlice(value); - holdersRight = isPartialRight ? replaceHolders(partialsRight, PLACEHOLDER) : baseSlice(funcHolders); - } - // append argument positions - value = data[7]; - if (value) { - value = baseSlice(value); - if (argPos) { - push.apply(value, argPos); - } - argPos = value; - } - // use metadata `arity` if not provided - if (arity == null) { - arity = data[8]; - } - } - if (arity == null) { - arity = isBindKey ? 0 : func.length; - } else { - arity = nativeMax(+arity || 0, 0); - } - if (oldPartials) { - arity = nativeMax(arity - (oldPartials.length - oldHolders.length), 0); - } + bitmask = newData[1]; if (bitmask == BIND_FLAG) { - var result = createBindWrapper(func, thisArg); - } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) { - result = createPartialWrapper(func, bitmask, partials, thisArg); + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(null, newData); } else { - result = createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity); + result = createHybridWrapper.apply(null, newData); } var setter = data ? baseSetData : setData; - return setter(result, [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, arity]); + return setter(result, newData); } /** @@ -3070,7 +3075,7 @@ result[index] = array[index]; } } - // add array properties assigned by `RegExp#exec` + // Add array properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; @@ -3084,7 +3089,8 @@ * @private * @param {Object} object The object to clone. * @param {boolean} [isDeep=false] Specify a deep clone. - * @returns {null|Object} Returns the initialized object clone. + * @returns {null|Object} Returns the initialized object clone if an object + * is cloneable, else `null`. */ function initObjectClone(object, isDeep) { if (!isCloneable(object)) { @@ -3177,7 +3183,7 @@ } /** - * Checks if `value` is valid array-like length. + * Checks if `value` is a valid array-like length. * * @private * @param {*} value The value to check. @@ -3199,6 +3205,56 @@ return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); } + /** + * Merges the function metadata of `source` into `data`. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ + function mergeData(data, source) { + var bitmask = data[1], + funcBitmask = source[1]; + + // Use metadata `thisArg` if available. + if (funcBitmask & BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + bitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : baseSlice(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : baseSlice(source[4]); + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : baseSlice(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : baseSlice(source[6]); + } + // Append argument positions. + value = source[7]; + if (value) { + value = baseSlice(value); + push.apply(value, data[7]); + data[7] = value; + } + // Use metadata `arity` if one is not provided. + if (data[8] == null) { + data[8] = source[8]; + } + // Use metadata `func` and merge bitmasks. + data[0] = source[0]; + data[1] = bitmask | funcBitmask; + + return data; + } + /** * A specialized version of `_.pick` that picks `object` properties * specified by the `props` array. @@ -3270,8 +3326,8 @@ * Sets metadata for `func`. * * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity - * function to avoid garbage collection pauses. + * period of time, it will trip its breaker and transition to an identity function + * to avoid garbage collection pauses in V8. See https://code.google.com/p/v8/issues/detail?id=2070. * * @private * @param {Function} func The function to associate metadata with. @@ -3311,7 +3367,7 @@ var Ctor, support = lodash.support; - // exit early for non `Object` objects + // Exit early for non `Object` objects. if (!(value && typeof value == 'object' && toString.call(value) == objectClass) || (!hasOwnProperty.call(value, 'constructor') && @@ -3411,8 +3467,11 @@ * // => [['a', 'b', 'c'], ['d']] */ function chunk(array, size, guard) { - size = (guard || size == null) ? 1 : nativeMax(+size || 1, 1); - + if (guard ? isIterateeCall(array, size, guard) : size == null) { + size = 1; + } else { + size = nativeMax(+size || 1, 1); + } var index = 0, length = array ? array.length : 0, resIndex = -1, @@ -3512,7 +3571,9 @@ * // => [1, 2, 3] */ function drop(array, n, guard) { - n = (guard || n == null) ? 1 : n; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } return slice(array, n < 0 ? 0 : n); } @@ -3542,9 +3603,10 @@ * // => [1, 2, 3] */ function dropRight(array, n, guard) { - var length = array ? array.length : 0; - n = (guard || n == null) ? 1 : n; - n = length - (n || 0); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = array ? (array.length - (+n || 0)) : 0; return slice(array, 0, n < 0 ? 0 : n); } @@ -3729,7 +3791,7 @@ * // => 2 * * // using "_.where" callback shorthand - * _.findLastIndex(users, { 'age': 40}); + * _.findLastIndex(users, { 'age': 40 }); * // => 1 * * // using "_.pluck" callback shorthand @@ -3791,7 +3853,10 @@ */ function flatten(array, isDeep, guard) { var length = array ? array.length : 0; - return length ? baseFlatten(array, guard ? false : isDeep) : []; + if (guard && isIterateeCall(array, isDeep, guard)) { + isDeep = false; + } + return length ? baseFlatten(array, isDeep) : []; } /** @@ -3815,8 +3880,8 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` * using `SameValueZero` for equality comparisons. If `fromIndex` is negative, - * it is used as the offset from the end of the collection. If `array` is - * sorted providing `true` for `fromIndex` performs a faster binary search. + * it is used as the offset from the end of `array`. If `array` is sorted + * providing `true` for `fromIndex` performs a faster binary search. * * **Note:** `SameValueZero` comparisons are like strict equality comparisons, * e.g. `===`, except that `NaN` matches `NaN`. See the @@ -4292,7 +4357,9 @@ * // => [] */ function take(array, n, guard) { - n = (guard || n == null) ? 1 : n; + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } return slice(array, 0, n < 0 ? 0 : n); } @@ -4322,9 +4389,10 @@ * // => [] */ function takeRight(array, n, guard) { - var length = array ? array.length : 0; - n = (guard || n == null) ? 1 : n; - n = length - (n || 0); + if (guard ? isIterateeCall(array, n, guard) : n == null) { + n = 1; + } + n = array ? (array.length - (+n || 0)) : 0; return slice(array, n < 0 ? 0 : n); } @@ -4501,7 +4569,7 @@ if (!length) { return []; } - // juggle arguments + // Juggle arguments. if (typeof isSorted != 'boolean' && isSorted != null) { thisArg = iteratee; iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; @@ -4682,10 +4750,10 @@ * ]; * * var youngest = _.chain(users) - * .sortBy('age') - * .map(function(chr) { return chr.user + ' is ' + chr.age; }) - * .first() - * .value(); + * .sortBy('age') + * .map(function(chr) { return chr.user + ' is ' + chr.age; }) + * .first() + * .value(); * // => 'pebbles is 1' */ function chain(value) { @@ -4763,9 +4831,9 @@ * // with explicit chaining * _(users).chain() * .first() - * .pick('age') + * .pick('user') * .value(); - * // => { 'age': 36 } + * // => { 'user': 'barney' } */ function wrapperChain() { return chain(this); @@ -4777,7 +4845,7 @@ * * **Note:** This method mutates the wrapped array. * - * @name chain + * @name reverse * @memberOf _ * @category Chain * @returns {Object} Returns the new reversed `lodash` object. @@ -4792,6 +4860,10 @@ * // => [3, 2, 1] */ function wrapperReverse() { + var value = this.__wrapped__; + if (value instanceof LazyWrapper) { + return new LodashWrapper(value.reverse()); + } return this.thru(function(value) { return value.reverse(); }); @@ -4816,41 +4888,25 @@ /** * Extracts the unwrapped value from its wrapper. * - * @name valueOf + * @name value * @memberOf _ - * @alias toJSON, value + * @alias toJSON, valueOf * @category Chain - * @returns {*} Returns the unwrapped value. + * @returns {*} Returns the resolved unwrapped value. * @example * - * _([1, 2, 3]).valueOf(); + * _([1, 2, 3]).value(); * // => [1, 2, 3] */ - function wrapperValueOf() { - var result = this.__wrapped__; - if (result instanceof LazyWrapper) { - result = result.value(); - } - var index = -1, - queue = this.__queue__, - length = queue.length; - - while (++index < length) { - var args = [result], - data = queue[index], - object = data.object; - - push.apply(args, data.args); - result = object[data.name].apply(object, args); - } - return result; + function wrapperValue() { + return baseWrapperValue(this.__wrapped__, this.__actions__); } /*------------------------------------------------------------------------*/ /** * Creates an array of elements corresponding to the specified keys, or indexes, - * of the collection. Keys may be specified as individual arguments or as arrays + * of `collection`. Keys may be specified as individual arguments or as arrays * of keys. * * @static @@ -4878,7 +4934,7 @@ /** * Checks if `value` is in `collection` using `SameValueZero` for equality * comparisons. If `fromIndex` is negative, it is used as the offset from - * the end of the collection. + * the end of `collection`. * * **Note:** `SameValueZero` comparisons are like strict equality comparisons, * e.g. `===`, except that `NaN` matches `NaN`. See the @@ -4887,7 +4943,7 @@ * * @static * @memberOf _ - * @alias include + * @alias contains, include * @category Collection * @param {Array|Object|string} collection The collection to search. * @param {*} target The value to search for. @@ -4895,19 +4951,19 @@ * @returns {boolean} Returns `true` if a matching element is found, else `false`. * @example * - * _.contains([1, 2, 3], 1); + * _.includes([1, 2, 3], 1); * // => true * - * _.contains([1, 2, 3], 1, 2); + * _.includes([1, 2, 3], 1, 2); * // => false * - * _.contains({ 'user': 'fred', 'age': 40 }, 'fred'); + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); * // => true * - * _.contains('pebbles', 'eb'); + * _.includes('pebbles', 'eb'); * // => true */ - function contains(collection, target, fromIndex) { + function includes(collection, target, fromIndex) { var length = collection ? collection.length : 0; if (!isLength(length)) { @@ -5152,11 +5208,11 @@ * { 'user': 'fred', 'age': 40, 'status': 'busy' } * ]; * - * _.findWhere(users, { 'status': 'busy' }); - * // => { 'user': 'barney', 'age': 36, 'status': 'busy' } + * _.result(_.findWhere(users, { 'status': 'busy' }), 'user'); + * // => 'barney' * - * _.findWhere(users, { 'age': 40 }); - * // => { 'user': 'fred', 'age': 40, 'status': 'busy' } + * _.result(_.findWhere(users, { 'age': 40 }), 'user'); + * // => 'fred' */ function findWhere(collection, source) { return find(collection, matches(source)); @@ -5262,7 +5318,7 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iteratee`. The corresponding value + * each element of `collection` through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). @@ -5304,10 +5360,10 @@ }); /** - * Invokes the method named by `methodName` on each element in the collection, + * Invokes the method named by `methodName` on each element in `collection`, * returning an array of the results of each invoked method. Any additional * arguments are provided to each invoked method. If `methodName` is a function - * it is invoked for, and `this` bound to, each element in the collection. + * it is invoked for, and `this` bound to, each element in `collection`. * * @static * @memberOf _ @@ -5330,7 +5386,7 @@ } /** - * Creates an array of values by running each element in the collection through + * Creates an array of values by running each element in `collection` through * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * @@ -5360,8 +5416,8 @@ * // => [3, 6, 9] (iteration order is not guaranteed) * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * // using "_.pluck" callback shorthand @@ -5376,11 +5432,11 @@ } /** - * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iteratee function is provided it - * is invoked for each value in the collection to generate the criterion by - * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of `collection`. If `collection` is empty or + * falsey `-Infinity` is returned. If an iteratee function is provided it is + * invoked for each value in `collection` to generate the criterion by which + * the value is ranked. The `iteratee` is bound to `thisArg` and invoked with + * three arguments; (value, index, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -5447,11 +5503,11 @@ } /** - * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iteratee function is provided it - * is invoked for each value in the collection to generate the criterion by - * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of `collection`. If `collection` is empty or + * falsey `Infinity` is returned. If an iteratee function is provided it is + * invoked for each value in `collection` to generate the criterion by which + * the value is ranked. The `iteratee` is bound to `thisArg` and invoked with + * three arguments; (value, index, collection). * * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. @@ -5566,7 +5622,7 @@ }, function() { return [[], []]; }); /** - * Retrieves the value of a specified property from all elements in the collection. + * Retrieves the value of a specified property from all elements in `collection`. * * @static * @memberOf _ @@ -5593,10 +5649,10 @@ } /** - * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iteratee`, where each successive + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` through `iteratee`, where each successive * invocation is supplied the return value of the previous. If `accumulator` - * is not provided the first element of the collection is used as the initial + * is not provided the first element of `collection` is used as the initial * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * @@ -5715,7 +5771,7 @@ * // => [3, 1] */ function sample(collection, n, guard) { - if (guard || n == null) { + if (guard ? isIterateeCall(collection, n, guard) : n == null) { collection = toIterable(collection); var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; @@ -5758,7 +5814,7 @@ } /** - * Gets the size of the collection by returning `collection.length` for + * Gets the size of `collection` by returning `collection.length` for * array-like values or the number of own enumerable properties for objects. * * @static @@ -5842,9 +5898,6 @@ * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an array of property names is provided for `iteratee` the collection - * is sorted by each property value. - * * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. @@ -5854,8 +5907,8 @@ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. * @param {Array|Function|Object|string} [iteratee=_.identity] The function - * invoked per iteration. If property name(s) or an object is provided it - * is used to create a "_.pluck" or "_.where" style callback respectively. + * invoked per iteration. If a property name or an object is provided it is + * used to create a "_.pluck" or "_.where" style callback respectively. * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example @@ -5867,55 +5920,74 @@ * // => [3, 1, 2] * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 26 }, - * { 'user': 'fred', 'age': 30 } + * { 'user': 'fred' }, + * { 'user': 'pebbles' }, + * { 'user': 'barney' } * ]; * * // using "_.pluck" callback shorthand - * _.map(_.sortBy(users, 'age'), _.values); - * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]] - * - * // sorting by multiple properties - * _.map(_.sortBy(users, ['user', 'age']), _.values); - * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + * _.pluck(_.sortBy(users, 'user'), 'user'); + * // => ['barney', 'fred', 'pebbles'] */ function sortBy(collection, iteratee, thisArg) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = null; } + iteratee = getCallback(iteratee, thisArg, 3); + var index = -1, length = collection ? collection.length : 0, - multi = iteratee && isArray(iteratee), - result = []; + result = isLength(length) ? Array(length) : []; - if (isLength(length)) { - result.length = length; - } - if (!multi) { - iteratee = getCallback(iteratee, thisArg, 3); - } baseEach(collection, function(value, key, collection) { - if (multi) { - var length = iteratee.length, - criteria = Array(length); + result[++index] = { 'criteria': iteratee(value, key, collection), 'index': index, 'value': value }; + }); + return baseSortBy(result, compareAscending); + } - while (length--) { - criteria[length] = value == null ? undefined : value[iteratee[length]]; - } - } else { - criteria = iteratee(value, key, collection); + /** + * This method is like `_.sortBy` except that it sorts by property names + * instead of an iteratee function. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {...(string|string[])} props The property names to sort by, + * specified as individual property names or arrays of property names. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 26 }, + * { 'user': 'fred', 'age': 30 } + * ]; + * + * _.map(_.sortByAll(users, ['user', 'age']), _.values); + * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + */ + function sortByAll(collection) { + var args = arguments; + if (args.length == 4 && isIterateeCall(args[1], args[2], args[3])) { + args = [collection, args[1]]; + } + var index = -1, + length = collection ? collection.length : 0, + props = baseFlatten(args, false, false, 1), + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value, key, collection) { + var length = props.length, + criteria = Array(length); + + while (length--) { + criteria[length] = value == null ? undefined : value[props[length]]; } result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); - - length = result.length; - result.sort(multi ? compareMultipleAscending : compareAscending); - while (length--) { - result[length] = result[length].value; - } - return result; + return baseSortBy(result, compareMultipleAscending); } /** @@ -6198,7 +6270,10 @@ * // => [1, 2, 3] */ function curry(func, arity, guard) { - var result = createWrapper(func, CURRY_FLAG, null, null, null, null, guard ? null : arity); + if (guard && isIterateeCall(func, arity, guard)) { + arity = null; + } + var result = createWrapper(func, CURRY_FLAG, null, null, null, null, arity); result.placeholder = curry.placeholder; return result; } @@ -6232,6 +6307,9 @@ * // => [1, 2, 3] */ function curryRight(func, arity, guard) { + if (guard && isIterateeCall(func, arity, guard)) { + arity = null; + } var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, guard ? null : arity); result.placeholder = curryRight.placeholder; return result; @@ -6461,9 +6539,9 @@ } /** - * Creates a function that invokes the provided functions with the `this` - * binding of the created function, where each successive invocation is - * supplied the return value of the previous. + * Creates a function that returns the result of invoking the provided + * functions with the `this` binding of the created function, where each + * successive invocation is supplied the return value of the previous. * * @static * @memberOf _ @@ -6661,8 +6739,8 @@ /** * Creates a function that invokes `func` with `partial` arguments prepended - * to those provided to the new function. This method is similar to `_.bind` - * except it does **not** alter the `this` binding. + * to those provided to the new function. This method is like `_.bind` except + * it does **not** alter the `this` binding. * * **Note:** This method does not set the `length` property of partially * applied functions. @@ -6691,8 +6769,8 @@ * This method is like `_.partial` except that partially applied arguments * are appended to those provided to the new function. * - * **Note:** This method does not set the `length` property of partially applied - * functions. + * **Note:** This method does not set the `length` property of partially + * applied functions. * * @static * @memberOf _ @@ -6735,7 +6813,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} [indexes] The arranged argument indexes, + * @param {...(number|number[])} indexes The arranged argument indexes, * specified as individual indexes or arrays of indexes. * @returns {Function} Returns the new function. * @example @@ -6868,8 +6946,8 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * var shallow = _.clone(users); @@ -6891,7 +6969,7 @@ * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - // juggle arguments + // Juggle arguments. if (typeof isDeep != 'boolean' && isDeep != null) { thisArg = customizer; customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; @@ -6924,8 +7002,8 @@ * @example * * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } + * { 'user': 'barney' }, + * { 'user': 'fred' } * ]; * * var deep = _.cloneDeep(users); @@ -7052,7 +7130,7 @@ return (value && typeof value == 'object' && value.nodeType === 1 && toString.call(value).indexOf('Element') > -1) || false; } - // fallback for environments without DOM support + // Fallback for environments without DOM support. if (!support.dom) { isElement = function(value) { return (value && typeof value == 'object' && value.nodeType === 1 && !isPlainObject(value)) || false; @@ -7215,17 +7293,17 @@ * // => false */ function isFunction(value) { - // Use `|| false` to avoid a Chakra bug in compatibility modes of IE 11. + // Avoid a Chakra JIT bug in compatibility modes of IE 11. // See https://github.com/jashkenas/underscore/issues/1621. return typeof value == 'function' || false; } - // fallback for environments that return incorrect `typeof` operator results - if (isFunction(/x/) || !Uint8Array || !isFunction(Uint8Array)) { + // Fallback for environments that return incorrect `typeof` operator results. + if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { isFunction = function(value) { - // the use of `Object#toString` avoids issues with the `typeof` operator + // The use of `Object#toString` avoids issues with the `typeof` operator // in older versions of Chrome and Safari which return 'function' for - // regexes and modern Safari which returns 'object' for typed array - // constructors + // regexes and Safari 8 equivalents which return 'object' for typed + // array constructors. return toString.call(value) == funcClass; }; } @@ -7253,7 +7331,7 @@ * // => false */ function isObject(value) { - // Avoid a V8 bug in Chrome 19-20. + // Avoid a V8 JIT bug in Chrome 19-20. // See https://code.google.com/p/v8/issues/detail?id=2291. var type = typeof value; return type == 'function' || (value && type == 'object') || false; @@ -7287,7 +7365,7 @@ */ function isNaN(value) { // `NaN` as a primitive is the only value that is not equal to itself - // (perform the `[[Class]]` check first to avoid errors with some host objects in IE) + // (perform the `[[Class]]` check first to avoid errors with some host objects in IE). return isNumber(value) && value != +value; } @@ -7534,7 +7612,9 @@ */ function create(prototype, properties, guard) { var result = baseCreate(prototype); - properties = guard ? null : properties; + if (guard && isIterateeCall(prototype, properties, guard)) { + properties = null; + } return properties ? baseAssign(result, properties) : result; } @@ -7832,8 +7912,9 @@ * // => { 'fred': ['first', 'third'], 'barney': ['second'] } */ function invert(object, multiValue, guard) { - multiValue = guard ? null : multiValue; - + if (guard && isIterateeCall(object, multiValue, guard)) { + multiValue = null; + } var index = -1, props = keys(object), length = props.length, @@ -8339,6 +8420,17 @@ * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't require escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. + * See [Mathias Bynens's article](http://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * Backticks are escaped because in Internet Explorer < 9, they can break out + * of attribute values or HTML comments. See [#102](http://html5sec.org/#102), + * [#108](http://html5sec.org/#108), and [#133](http://html5sec.org/#133) of + * the [HTML5 Security Cheatsheet](http://html5sec.org/) for more details. + * * When working with HTML you should always quote attribute values to reduce * XSS vectors. See [Ryan Grove's article](http://wonko.com/post/html-escaping) * for more details. @@ -8354,7 +8446,7 @@ * // => 'fred, barney, & pebbles' */ function escape(string) { - // reset `lastIndex` because in IE < 9 `String#replace` does not + // Reset `lastIndex` because in IE < 9 `String#replace` does not. string = string == null ? '' : String(string); return string && (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) @@ -8531,8 +8623,8 @@ } string = String(string); - // leverage the exponentiation by squaring algorithm for a faster repeat - // http://en.wikipedia.org/wiki/Exponentiation_by_squaring + // Leverage the exponentiation by squaring algorithm for a faster repeat. + // See http://en.wikipedia.org/wiki/Exponentiation_by_squaring. do { if (n % 2) { result += string; @@ -8692,10 +8784,8 @@ * '); */ function template(string, options, otherOptions) { - // based on John Resig's `tmpl` implementation - // http://ejohn.org/blog/javascript-micro-templating/ - // and Laura Doktorova's doT.js - // https://github.com/olado/doT + // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/) + // and Laura Doktorova's doT.js (https://github.com/olado/doT). var settings = lodash.templateSettings; if (otherOptions && isIterateeCall(string, options, otherOptions)) { @@ -8714,7 +8804,7 @@ interpolate = options.interpolate || reNoMatch, source = "__p += '"; - // compile the regexp to match each delimiter + // Compile the regexp to match each delimiter. var reDelimiters = RegExp( (options.escape || reNoMatch).source + '|' + interpolate.source + '|' + @@ -8722,18 +8812,18 @@ (options.evaluate || reNoMatch).source + '|$' , 'g'); - // use a sourceURL for easier debugging - // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + // Use a sourceURL for easier debugging. + // See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl. var sourceURL = 'sourceURL' in options ? options.sourceURL : ('/lodash/template/source[' + (++templateCounter) + ']'); - sourceURL = sourceURL ? ('\n//# sourceURL=' + sourceURL) : ''; + sourceURL = sourceURL ? ('//# sourceURL=' + sourceURL + '\n') : ''; string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { interpolateValue || (interpolateValue = esTemplateValue); - // escape characters that can't be included in string literals + // Escape characters that can't be included in string literals. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); - // replace delimiters with snippets + // Replace delimiters with snippets. if (escapeValue) { isEscaping = true; source += "' +\n__e(" + escapeValue + ") +\n'"; @@ -8747,25 +8837,25 @@ } index = offset + match.length; - // the JS engine embedded in Adobe products requires returning the `match` - // string in order to produce the correct `offset` value + // The JS engine embedded in Adobe products requires returning the `match` + // string in order to produce the correct `offset` value. return match; }); source += "';\n"; - // if `variable` is not specified, wrap a with-statement around the generated - // code to add the data object to the top of the scope chain + // If `variable` is not specified, wrap a with-statement around the generated + // code to add the data object to the top of the scope chain. var variable = options.variable; if (!variable) { source = 'with (obj) {\n' + source + '\n}\n'; } - // cleanup code by stripping empty strings + // Cleanup code by stripping empty strings. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) .replace(reEmptyStringMiddle, '$1') .replace(reEmptyStringTrailing, '$1;'); - // frame code as the function body + // Frame code as the function body. source = 'function(' + (variable || 'obj') + ') {\n' + (variable ? '' @@ -8785,11 +8875,11 @@ 'return __p\n}'; var result = attempt(function() { - return Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues); + return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues); }); - // provide the compiled function's source by its `toString` method or - // the `source` property as a convenience for inlining compiled templates + // Provide the compiled function's source by its `toString` method or + // the `source` property as a convenience for inlining compiled templates. result.source = source; if (isError(result)) { throw result; @@ -8820,7 +8910,7 @@ if (!string) { return string; } - if (guard || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1); } chars = String(chars); @@ -8845,12 +8935,12 @@ * _.trimLeft('-_-fred-_-', '_-'); * // => 'fred-_-' */ - function trimLeft(string, chars, guards) { + function trimLeft(string, chars, guard) { string = string == null ? '' : String(string); if (!string) { return string; } - if (guards || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(trimmedLeftIndex(string)) } chars = String(chars); @@ -8880,7 +8970,7 @@ if (!string) { return string; } - if (guard || chars == null) { + if (guard ? isIterateeCall(string, chars, guard) : chars == null) { return string.slice(0, trimmedRightIndex(string) + 1) } chars = String(chars); @@ -8920,8 +9010,9 @@ * // => 'hi-diddly-ho there, neig [...]' */ function trunc(string, options, guard) { - options = guard ? null : options; - + if (guard && isIterateeCall(string, options, guard)) { + options = null; + } var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; @@ -9014,7 +9105,9 @@ */ function words(string, pattern, guard) { string = string != null && String(string); - pattern = guard ? null : pattern; + if (guard && isIterateeCall(string, pattern, guard)) { + pattern = null; + } return (string && string.match(pattern || reWords)) || []; } @@ -9080,11 +9173,14 @@ * }; * }); * - * _.filter(users, 'age__gt38'); + * _.filter(users, 'age__gt36'); * // => [{ 'user': 'fred', 'age': 40 }] */ function callback(func, thisArg, guard) { - return baseCallback(func, guard ? undefined : thisArg); + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = null; + } + return baseCallback(func, thisArg); } /** @@ -9269,8 +9365,8 @@ var chainAll = this.__chain__; if (chain || chainAll) { var result = object(this.__wrapped__); + (result.__actions__ = baseSlice(this.__actions__)).push({ 'args': arguments, 'object': object, 'name': methodName }); result.__chain__ = chainAll; - (result.__queue__ = baseSlice(this.__queue__)).push({ 'args': arguments, 'object': object, 'name': methodName }); return result; } var args = [this.value()]; @@ -9313,7 +9409,7 @@ * // => true */ function noop() { - // no operation performed + // No operation performed. } /** @@ -9353,16 +9449,19 @@ * // => 8 */ function parseInt(value, radix, guard) { - return nativeParseInt(value, guard ? 0 : radix); + if (guard && isIterateeCall(value, radix, guard)) { + radix = 0; + } + return nativeParseInt(value, radix); } - // fallback for environments with pre-ES5 implementations + // Fallback for environments with pre-ES5 implementations. if (nativeParseInt(whitespace + '08') != 8) { parseInt = function(value, radix, guard) { // Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and // Chrome fails to trim leading whitespace characters. // See https://code.google.com/p/v8/issues/detail?id=3109. value = trim(value); - radix = guard ? 0 : +radix; + radix = (guard && isIterateeCall(value, radix, guard)) ? 0 : +radix; return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10)); }; } @@ -9379,8 +9478,8 @@ * @example * * var users = [ - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } + * { 'user': 'fred' }, + * { 'user': 'barney' } * ]; * * var getName = _.property('user'); @@ -9530,8 +9629,8 @@ } else { end = +end || 0; } - // use `Array(length)` so engines like Chakra and V8 avoid slower modes - // http://youtu.be/XAqIpGU8ZZk#t=17m25s + // Use `Array(length)` so engines like Chakra and V8 avoid slower modes. + // See http://youtu.be/XAqIpGU8ZZk#t=17m25s. var index = -1, length = nativeMax(ceil((end - start) / (step || 1)), 0), result = Array(length); @@ -9608,7 +9707,13 @@ * // => also invokes `mage.castSpell(n)` three times */ function times(n, iteratee, thisArg) { - n = nativeIsFinite(n = +n) && n > -1 ? n : 0; + n = +n; + + // Exit early to avoid a JSC JIT bug in Safari 8 + // where `Array(0)` is treated as `Array(1)`. + if (n < 1 || !nativeIsFinite(n)) { + return []; + } iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, @@ -9647,21 +9752,22 @@ /*------------------------------------------------------------------------*/ - // ensure `new LodashWrapper` is an instance of `lodash` + // Ensure `new LodashWrapper` is an instance of `lodash`. LodashWrapper.prototype = lodash.prototype; - // add functions to the `Map` cache + // Add functions to the `Map` cache. + MapCache.prototype['delete'] = mapDelete; MapCache.prototype.get = mapGet; MapCache.prototype.has = mapHas; MapCache.prototype.set = mapSet; - // add functions to the `Set` cache + // Add functions to the `Set` cache. SetCache.prototype.push = cachePush; - // assign cache to `_.memoize` + // Assign cache to `_.memoize`. memoize.Cache = MapCache; - // add functions that return wrapped values when chaining + // Add functions that return wrapped values when chaining. lodash.after = after; lodash.assign = assign; lodash.at = at; @@ -9734,6 +9840,7 @@ lodash.shuffle = shuffle; lodash.slice = slice; lodash.sortBy = sortBy; + lodash.sortByAll = sortByAll; lodash.take = take; lodash.takeRight = takeRight; lodash.takeRightWhile = takeRightWhile; @@ -9756,7 +9863,7 @@ lodash.zip = zip; lodash.zipObject = zipObject; - // add aliases + // Add aliases. lodash.backflow = flowRight; lodash.collect = map; lodash.compose = flowRight; @@ -9770,18 +9877,17 @@ lodash.tail = rest; lodash.unique = uniq; - // add functions to `lodash.prototype` + // Add functions to `lodash.prototype`. mixin(lodash, lodash); /*------------------------------------------------------------------------*/ - // add functions that return unwrapped values when chaining + // Add functions that return unwrapped values when chaining. lodash.attempt = attempt; lodash.camelCase = camelCase; lodash.capitalize = capitalize; lodash.clone = clone; lodash.cloneDeep = cloneDeep; - lodash.contains = contains; lodash.deburr = deburr; lodash.endsWith = endsWith; lodash.escape = escape; @@ -9797,6 +9903,7 @@ lodash.first = first; lodash.has = has; lodash.identity = identity; + lodash.includes = includes; lodash.indexOf = indexOf; lodash.isArguments = isArguments; lodash.isArray = isArray; @@ -9850,14 +9957,15 @@ lodash.uniqueId = uniqueId; lodash.words = words; - // add aliases + // Add aliases. lodash.all = every; lodash.any = some; + lodash.contains = includes; lodash.detect = find; lodash.foldl = reduce; lodash.foldr = reduceRight; lodash.head = first; - lodash.include = contains; + lodash.include = includes; lodash.inject = reduce; mixin(lodash, (function() { @@ -9872,11 +9980,10 @@ /*------------------------------------------------------------------------*/ - // add functions capable of returning wrapped and unwrapped values when chaining + // Add functions capable of returning wrapped and unwrapped values when chaining. lodash.sample = sample; - lodash.prototype.sample = function(n, guard) { - n = guard ? null : n; + lodash.prototype.sample = function(n) { if (!this.__chain__ && n == null) { return lodash.sample(this.value()); } @@ -9896,14 +10003,14 @@ */ lodash.VERSION = VERSION; - // assign default placeholders + // Assign default placeholders. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { lodash[methodName].placeholder = lodash; }); - // add `LazyWrapper` methods that accept an `iteratee` value + // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var isFilter = !index; + var isFilter = index == LAZY_FILTER_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); @@ -9912,13 +10019,13 @@ filtered = result.filtered, iteratees = result.iteratees || (result.iteratees = []); - result.filtered = filtered || index == LAZY_FILTER_FLAG || (index == LAZY_WHILE_FLAG && result.dir < 0); + result.filtered = filtered || isFilter || (index == LAZY_WHILE_FLAG && result.dir < 0); iteratees.push({ 'iteratee': iteratee, 'type': index }); return result; }; }); - // add `LazyWrapper` methods for `_.drop` and `_.take` variants + // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. arrayEach(['drop', 'take'], function(methodName, index) { var countName = methodName + 'Count', whileName = methodName + 'While'; @@ -9946,7 +10053,7 @@ }; }); - // add `LazyWrapper` methods for `_.first` and `_.last` + // Add `LazyWrapper` methods for `_.first` and `_.last`. arrayEach(['first', 'last'], function(methodName, index) { var takeName = 'take' + (index ? 'Right': ''); @@ -9955,7 +10062,7 @@ }; }); - // add `LazyWrapper` methods for `_.initial` and `_.rest` + // Add `LazyWrapper` methods for `_.initial` and `_.rest`. arrayEach(['initial', 'rest'], function(methodName, index) { var dropName = 'drop' + (index ? '' : 'Right'); @@ -9964,6 +10071,16 @@ }; }); + // Add `LazyWrapper` methods for `_.pluck` and `_.where`. + arrayEach(['pluck', 'where'], function(methodName, index) { + var operationName = index ? 'filter' : 'map', + createCallback = index ? matches : property; + + LazyWrapper.prototype[methodName] = function(value) { + return this[operationName](createCallback(value)); + }; + }); + LazyWrapper.prototype.dropWhile = function(iteratee, thisArg) { iteratee = getCallback(iteratee, thisArg, 3); @@ -9997,34 +10114,43 @@ return result; }; - // add `LazyWrapper` methods to `lodash.prototype` + // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var args = arguments, + var value = this.__wrapped__, + args = arguments, chainAll = this.__chain__, - value = this.__wrapped__, - isLazy = value instanceof LazyWrapper; + isHybrid = !!this.__actions__.length, + isLazy = value instanceof LazyWrapper, + onlyLazy = isLazy && !isHybrid; if (retUnwrapped && !chainAll) { - return isLazy + return onlyLazy ? func.call(value) : lodash[methodName](this.value()); } - if (isLazy || isArray(value)) { - var result = func.apply(isLazy ? value : new LazyWrapper(this), args); - return new LodashWrapper(result, chainAll); - } - return this.thru(function(value) { + var interceptor = function(value) { var otherArgs = [value]; push.apply(otherArgs, args); return lodash[methodName].apply(lodash, otherArgs); - }); + }; + if (isLazy || isArray(value)) { + var wrapper = onlyLazy ? value : new LazyWrapper(this), + result = func.apply(wrapper, args); + + if (!retUnwrapped && (isHybrid || result.actions)) { + var actions = result.actions || (result.actions = []); + actions.push({ 'args': [interceptor], 'object': lodash, 'name': 'thru' }); + } + return new LodashWrapper(result, chainAll); + } + return this.thru(interceptor); }; }); - // add `Array.prototype` functions to `lodash.prototype` + // Add `Array.prototype` functions to `lodash.prototype`. arrayEach(['concat', 'join', 'pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', @@ -10041,18 +10167,18 @@ }; }); - // add functions to the lazy wrapper + // Add functions to the lazy wrapper. LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // add chaining functions to the lodash wrapper + // Add chaining functions to the lodash wrapper. lodash.prototype.chain = wrapperChain; lodash.prototype.reverse = wrapperReverse; lodash.prototype.toString = wrapperToString; - lodash.prototype.toJSON = lodash.prototype.value = lodash.prototype.valueOf = wrapperValueOf; + lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - // add function aliases to the lodash wrapper + // Add function aliases to the lodash wrapper. lodash.prototype.collect = lodash.prototype.map; lodash.prototype.head = lodash.prototype.first; lodash.prototype.select = lodash.prototype.filter; @@ -10063,35 +10189,35 @@ /*--------------------------------------------------------------------------*/ - // export Lo-Dash + // Export Lo-Dash. var _ = runInContext(); - // some AMD build optimizers like r.js check for condition patterns like the following: + // Some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { // Expose Lo-Dash to the global object when an AMD loader is present to avoid // errors in cases where Lo-Dash is loaded by a script tag and not intended - // as an AMD module. See http://requirejs.org/docs/errors.html#mismatch + // as an AMD module. See http://requirejs.org/docs/errors.html#mismatch. root._ = _; - // define as an anonymous module so, through path mapping, it can be - // referenced as the "underscore" module + // Define as an anonymous module so, through path mapping, it can be + // referenced as the "underscore" module. define(function() { return _; }); } - // check for `exports` after `define` in case a build optimizer adds an `exports` object + // Check for `exports` after `define` in case a build optimizer adds an `exports` object. else if (freeExports && freeModule) { - // in Node.js or RingoJS + // Export for Node.js or RingoJS. if (moduleExports) { (freeModule.exports = _)._ = _; } - // in Narwhal or Rhino -require + // Export for Narwhal or Rhino -require. else { freeExports._ = _; } } else { - // in a browser or Rhino + // Export for a browser or Rhino. root._ = _; } }.call(this)); diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 3a9d00b83..e81c9c29f 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,78 +4,80 @@ * Build: `lodash modern -o ./dist/lodash.js` */ ;(function(){function n(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n) -}function w(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Pt(n){for(var t=-1,r=n.length,e=Yu;++tu(t,i)&&f.push(i);return f}function nr(n,t){var r=n?n.length:0;if(!Br(r))return lr(n,t);for(var e=-1,u=Gr(n);++ec))return false}else{var g=p&&mu.call(n,"__wrapped__"),h=h&&mu.call(t,"__wrapped__");if(g||h)return pr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(l){case vt:case yt:return+n==+t;case _t:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case wt:case xt:return n==pu(t)}return false}if(g=c?cu:n.constructor,l=i?cu:t.constructor,f){if(g.prototype.name!=l.prototype.name)return false}else if(p=!c&&mu.call(n,"constructor"),h=!i&&mu.call(t,"constructor"),p!=h||!p&&g!=l&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof l=="function"&&l instanceof l))return false; -if(g=f?["message","name"]:ho(n),l=f?g:ho(t),c&&g.push("length"),i&&l.push("length"),c=g.length,p=l.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;if(u.push(n),o.push(t),i=true,a)for(;i&&++le(f,s)&&((t||i)&&f.push(s),l.push(c))}return l}function wr(n,t){for(var r=-1,e=t(n),u=e.length,o=uu(u);++rt||null==r)return r; -if(3t?0:t)}function Xr(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),re(n,0,0>t?0:t)}function Hr(n,t,r){var e=-1,u=n?n.length:0;for(t=Fr(t,r,3);++er?zu(e+r,0):r||0;else if(r)return r=ee(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return a(n,t,r)}function te(n){return Jr(n,1)}function re(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&zr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n);for(u=t>r?0:r-t,r=uu(u);++er?zu(e+r,0):r||0:0,typeof n=="string"||!lo(n)&&ze(n)?ri||r===Vu&&r===f)&&(i=r,f=n) -}),f}function de(n,t){return ve(n,eu(t))}function me(n,t,r,e){return(lo(n)?u:dr)(n,Fr(t,e,4),r,3>arguments.length,nr)}function _e(n,t,r,e){return(lo(n)?o:dr)(n,Fr(t,e,4),r,3>arguments.length,tr)}function be(n){n=Zr(n);for(var t=-1,r=n.length,e=uu(r);++t=r||r>t?(f&&Iu(f),r=p,f=s=p=E,r&&(h=_o(),a=n.apply(c,i),s||f||(i=c=null))):s=Su(e,r) -}function u(){s&&Iu(s),f=s=p=E,(v||g!==t)&&(h=_o(),a=n.apply(c,i),s||f||(i=c=null))}function o(){if(i=arguments,l=_o(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=l);var o=g-(l-h),d=0>=o||o>g;d?(f&&(f=Iu(f)),h=l,a=n.apply(c,i)):f||(f=Su(u,o))}return d&&s?s=Iu(s):s||t===g||(s=Su(e,t)),r&&(d=true,a=n.apply(c,i)),!d||s||f||(i=c=null),a}var i,f,a,l,c,s,p,h=0,g=false,v=true;if(!Fe(n))throw new hu(M);if(t=0>t?0:t,true===r)var y=true,v=false;else Ue(r)&&(y=r.leading,g="maxWait"in r&&zu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v); -return o.cancel=function(){s&&Iu(s),f&&Iu(f),f=s=p=E},o}function Oe(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,Fe))throw new hu(M);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Re(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(!Fe(n)||t&&!Fe(t))throw new hu(M);return r.cache=new Re.Cache,r}function Ce(n){var t=re(arguments,1),r=w(t,Ce.placeholder); -return Wr(n,N,null,t,r)}function Se(n){var t=re(arguments,1),r=w(t,Se.placeholder);return Wr(n,W,null,t,r)}function Te(n){return Br(n&&typeof n=="object"?n.length:E)&&bu.call(n)==ht||false}function Ne(n){return n&&typeof n=="object"&&1===n.nodeType&&-1t||null==n||!qu(t))return r;n=pu(n);do t%2&&(r+=n),t=Eu(t/2),n+=n;while(t);return r}function Ye(n,t,r){return(n=null==n?"":pu(n))?r||null==t?n.slice(x(n),j(n)+1):(t=pu(t),n.slice(s(n,t),p(n,t)+1)):n}function Ze(n,t,r){return(n=null!=n&&pu(n))&&n.match((r?null:t)||ct)||[] -}function Ge(n){try{return n()}catch(t){return We(t)?t:iu(t)}}function Je(n,t,r){return Jt(n,r?E:t)}function Xe(n){return function(){return n}}function He(n){return n}function Qe(n){var t=ho(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Dr(u))return function(n){return null!=n&&u===n[e]&&mu.call(n,e)}}for(var o=r,i=uu(r),f=uu(r);o--;){var u=n[t[o]],a=Dr(u);i[o]=a?u:Xt(u,true,jr),f[o]=a}return function(n){if(o=r,null==n)return!o;for(;o--;)if(f[o]?i[o]!==n[t[o]]:!mu.call(n,t[o]))return false;for(o=r;o--;)if(f[o]?!mu.call(n,t[o]):!pr(i[o],n[t[o]],null,true))return false; -return true}}function nu(n,t,r){var e=true,u=Ue(t),o=null==r,i=o&&u&&ho(t),f=i&&sr(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=sr(t,ho(t))),false===r?e=false:Ue(r)&&"chain"in r&&(e=r.chain),r=-1,u=Fe(n);for(o=f.length;++r=q)return r}else n=0;return no(r,e)}}(),uo=Er(function(n,t,r){mu.call(n,r)?++n[r]:n[r]=1}),oo=Er(function(n,t,r){mu.call(n,r)?n[r].push(t):n[r]=[t]}),io=Er(function(n,t,r){n[r]=t}),fo=Er(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),ao=Wr(xe,N,null,[2]),lo=$u||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&bu.call(n)==gt||false -};Qu.dom||(Ne=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!so(n)||false});var co=Mu||function(n){return typeof n=="number"&&qu(n)};!Fe(/x/)&&Nu&&Fe(Nu)||(Fe=function(n){return bu.call(n)==mt});var so=ku?function(n){if(!n||bu.call(n)!=bt)return false;var t=n.valueOf,r=$e(t)&&(r=ku(t))&&ku(r);return r?n==r||ku(n)==r:Vr(n)}:Vr,po=kr(Zt),ho=Lu?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},Ut.assign=po,Ut.at=function(n){return(!n||Br(n.length))&&(n=Zr(n)),Gt(n,or(arguments,false,false,1))},Ut.before=xe,Ut.bind=je,Ut.bindAll=function(n){for(var t=n,r=1(s?Dt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?Dt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i) -}return c},Ut.invert=function(n,t,r){t=r?null:t,r=-1;for(var e=ho(n),u=e.length,o={};++rt?0:t)},Ut.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((r||null==t?1:t)||0),re(n,0>t?0:t)},Ut.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Fr(t,r,3);e--&&t(n[e],e,n););return re(n,e+1)},Ut.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Fr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Ut.escape=function(n){return(n=null==n?"":pu(n))&&(J.lastIndex=0,J.test(n))?n.replace(J,y):n},Ut.escapeRegExp=Ke,Ut.every=ce,Ut.find=pe,Ut.findIndex=Hr,Ut.findKey=function(n,t,r){return t=Fr(t,r,3),ur(n,t,lr,true)},Ut.findLast=function(n,t,r){return t=Fr(t,r,3),ur(n,t,tr) -},Ut.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Fr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Ut.findLastKey=function(n,t,r){return t=Fr(t,r,3),ur(n,t,cr,true)},Ut.findWhere=function(n,t){return pe(n,Qe(t))},Ut.first=Qr,Ut.has=function(n,t){return n?mu.call(n,t):false},Ut.identity=He,Ut.indexOf=ne,Ut.isArguments=Te,Ut.isArray=lo,Ut.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&bu.call(n)==vt||false},Ut.isDate=function(n){return n&&typeof n=="object"&&bu.call(n)==yt||false -},Ut.isElement=Ne,Ut.isEmpty=function(n){if(null==n)return true;var t=n.length;return Br(t)&&(lo(n)||ze(n)||Te(n)||typeof n=="object"&&Fe(n.splice))?!t:!ho(n).length},Ut.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Jt(r,e,3),!r&&Dr(n)&&Dr(t)?n===t:pr(n,t,r)},Ut.isError=We,Ut.isFinite=co,Ut.isFunction=Fe,Ut.isNaN=function(n){return qe(n)&&n!=+n},Ut.isNative=$e,Ut.isNull=function(n){return null===n},Ut.isNumber=qe,Ut.isObject=Ue,Ut.isPlainObject=so,Ut.isRegExp=Le,Ut.isString=ze,Ut.isUndefined=function(n){return typeof n=="undefined" -},Ut.kebabCase=yo,Ut.last=function(n){var t=n?n.length:0;return t?n[t-1]:E},Ut.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?zu(e+r,0):Bu(r||0,e-1))+1;else if(r)return u=ue(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return m(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Ut.max=ye,Ut.min=function(n,t,r){r&&zr(n,t,r)&&(t=null);var e=null==t,u=e&&lo(n),o=!u&&ze(n);if(e&&!o)return Pt(u?n:Zr(n));var i=Yu,f=i;return t=e&&o?c:Fr(t,r,3),nr(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Ut.template=function(n,t,r){var e=Ut.templateSettings;r&&zr(n,t,r)&&(t=r=null),n=pu(null==n?"":n),t=po({},r||t,e,Yt),r=po({},t.imports,e.imports,Yt); -var u,o,i=ho(r),f=Me(r),a=0;r=t.interpolate||it;var l="__p+='";if(r=su((t.escape||it).source+"|"+r.source+"|"+(r===Q?nt:it).source+"|"+(t.evaluate||it).source+"|$","g"),n.replace(r,function(t,r,e,i,f,c){return e||(e=i),l+=n.slice(a,c).replace(lt,d),r&&(u=true,l+="'+__e("+r+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(V,""):l).replace(Y,"$1").replace(Z,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Ge(function(){return fu(i,"return "+l).apply(E,f) -}),t.source=l,We(t))throw t;return t},Ut.trim=Ye,Ut.trimLeft=function(n,t,r){return(n=null==n?"":pu(n))?r||null==t?n.slice(x(n)):(t=pu(t),n.slice(s(n,t))):n},Ut.trimRight=function(n,t,r){return(n=null==n?"":pu(n))?r||null==t?n.slice(0,j(n)+1):(t=pu(t),n.slice(0,p(n,t)+1)):n},Ut.trunc=function(n,t,r){t=r?null:t;var e=U;if(r=$,Ue(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?pu(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":pu(n),e>=n.length)return n; -if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(Le(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=su(u.source,(tt.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Ut.prototype.sample=function(n,t){return n=t?null:n,this.__chain__||null!=n?this.thru(function(t){return Ut.sample(t,n)}):Ut.sample(this.value())},Ut.VERSION=k,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Ut[n].placeholder=Ut}),n(["filter","map","takeWhile"],function(n,t){qt.prototype[n]=function(n,r){n=Fr(n,r,3); -var e=this.clone(),u=e.filtered,o=e.iteratees||(e.iteratees=[]);return e.filtered=u||t==z||t==D&&0>e.dir,o.push({iteratee:n,type:t}),e}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";qt.prototype[n]=function(e){e=null==e?1:zu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?Bu(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},qt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},qt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse() -}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");qt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");qt.prototype[n]=function(){return this[r](1)}}),qt.prototype.dropWhile=function(n,t){n=Fr(n,t,3);var r,e,u=0>this.dir;return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},qt.prototype.reject=function(n,t){return n=Fr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},qt.prototype.slice=function(n,t){n=null==n?0:+n||0; -var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},lr(qt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);Ut.prototype[t]=function(){var e=arguments,u=this.__chain__,o=this.__wrapped__,i=o instanceof qt;return r&&!u?i?n.call(o):Ut[t](this.value()):i||lo(o)?(o=n.apply(i?o:new qt(this),e),new $t(o,u)):this.thru(function(n){return n=[n],Ou.apply(n,e),Ut[t].apply(Ut,n)})}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=gu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n); -Ut.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),qt.prototype.clone=function(){var n=this.iteratees,t=this.views,r=new qt(this.wrapped);return r.dir=this.dir,r.dropCount=this.dropCount,r.filtered=this.filtered,r.iteratees=n?l(n):null,r.takeCount=this.takeCount,r.views=t?l(t):null,r},qt.prototype.reverse=function(){var n=this.filtered,t=n?new qt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t},qt.prototype.value=function(){var n,t=this.wrapped.value(),r=this.dir,e=0>r,u=t.length; -n=u;for(var o=this.views,i=0,f=-1,a=o?o.length:0;++f"'`]/g,X=/<%-([\s\S]+?)%>/g,H=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,nt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tt=/\w*$/,rt=/^\s*function[ \n\r\t]+\w/,et=/^0[xX]/,ut=/^\[object .+?Constructor\]$/,ot=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,it=/($^)/,ft=/[.*+?^${}()|[\]\/\\]/g,at=/\bthis\b/,lt=/['\n\r\u2028\u2029\\]/g,ct=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),st=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",pt="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),ht="[object Arguments]",gt="[object Array]",vt="[object Boolean]",yt="[object Date]",dt="[object Error]",mt="[object Function]",_t="[object Number]",bt="[object Object]",wt="[object RegExp]",xt="[object String]",jt="[object ArrayBuffer]",At="[object Float32Array]",It="[object Float64Array]",Et="[object Int8Array]",kt="[object Int16Array]",Ot="[object Int32Array]",Rt="[object Uint8Array]",Ct="[object Uint8ClampedArray]",St="[object Uint16Array]",Tt="[object Uint32Array]",Nt={}; -Nt[ht]=Nt[gt]=Nt[At]=Nt[It]=Nt[Et]=Nt[kt]=Nt[Ot]=Nt[Rt]=Nt[Ct]=Nt[St]=Nt[Tt]=true,Nt[jt]=Nt[vt]=Nt[yt]=Nt[dt]=Nt[mt]=Nt["[object Map]"]=Nt[_t]=Nt[bt]=Nt[wt]=Nt["[object Set]"]=Nt[xt]=Nt["[object WeakMap]"]=false;var Wt={};Wt[ht]=Wt[gt]=Wt[jt]=Wt[vt]=Wt[yt]=Wt[At]=Wt[It]=Wt[Et]=Wt[kt]=Wt[Ot]=Wt[_t]=Wt[bt]=Wt[wt]=Wt[xt]=Wt[Rt]=Wt[Ct]=Wt[St]=Wt[Tt]=true,Wt[dt]=Wt[mt]=Wt["[object Map]"]=Wt["[object Set]"]=Wt["[object WeakMap]"]=false;var Ft={leading:false,maxWait:0,trailing:false},Ut={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},$t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},qt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Lt={"function":true,object:true},zt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Lt[typeof window]&&window!==(this&&this.window)?window:this,Dt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Mt=Lt[typeof module]&&module&&!module.nodeType&&module,Pt=Dt&&Mt&&typeof global=="object"&&global; -!Pt||Pt.global!==Pt&&Pt.window!==Pt&&Pt.self!==Pt||(Bt=Pt);var Kt=Mt&&Mt.exports===Dt&&Dt,Vt=I();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Vt, define(function(){return Vt})):Dt&&Mt?Kt?(Mt.exports=Vt)._=Vt:Dt._=Vt:Bt._=Vt}).call(this); \ No newline at end of file +return r}function i(n,t){for(var r=-1,e=n.length;++rt||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function x(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Kt(n){for(var t=-1,r=n.length,e=Gu;++to(t,f)&&e.push(f);return e}function tr(n,t){var r=n?n.length:0;if(!qr(r))return cr(n,t);for(var e=-1,u=Xr(n);++ec))return false}else{var g=p&&bu.call(n,"__wrapped__"),h=h&&bu.call(t,"__wrapped__");if(g||h)return hr(g?n.value():n,h?t.value():t,r,e,u,o);if(!s)return false;if(!f&&!p){switch(l){case yt:case dt:return+n==+t;case bt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case xt:case jt:return n==gu(t)}return false}if(g=c?pu:n.constructor,l=i?pu:t.constructor,f){if(g.prototype.name!=l.prototype.name)return false +}else if(p=!c&&bu.call(n,"constructor"),h=!i&&bu.call(t,"constructor"),p!=h||!p&&g!=l&&"constructor"in n&&"constructor"in t&&!(typeof g=="function"&&g instanceof g&&typeof l=="function"&&l instanceof l))return false;if(g=f?["message","name"]:vo(n),l=f?g:vo(t),c&&g.push("length"),i&&l.push("length"),c=g.length,p=l.length,c!=p&&!e)return false}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;if(u.push(n),o.push(t),i=true,a)for(;i&&++le(f,s)&&((t||i)&&f.push(s),l.push(c))}return l}function xr(n,t){for(var r=-1,e=t(n),u=e.length,o=iu(u);++rt||null==r)return r;if(3t?0:t)}function Qr(n,t,r){return(r?Mr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ue(n,0,0>t?0:t) +}function ne(n,t,r){var e=-1,u=n?n.length:0;for(t=$r(t,r,3);++er?Mu(e+r,0):r||0;else if(r)return r=oe(n,t),n=n[r],(t===t?t===n:n!==n)?r:-1;return a(n,t,r)}function ee(n){return Hr(n,1)}function ue(n,t,r){var e=-1,u=n?n.length:0,o=typeof r;if(r&&"number"!=o&&Mr(n,t,r)&&(t=0,r=u),t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r="undefined"==o||r>u?u:+r||0,0>r&&(r+=u),r&&r==u&&!t)return l(n); +for(u=t>r?0:r-t,r=iu(u);++er?Mu(e+r,0):r||0:0,typeof n=="string"||!so(n)&&Me(n)?ri||r===Zu&&r===f)&&(i=r,f=n)}),f}function _e(n,t){return de(n,ou(t))}function be(n,t,r,e){return(so(n)?u:mr)(n,$r(t,e,4),r,3>arguments.length,tr)}function we(n,t,r,e){return(so(n)?o:mr)(n,$r(t,e,4),r,3>arguments.length,rr)}function xe(n){n=Jr(n);for(var t=-1,r=n.length,e=iu(r);++t=r||r>t?(f&&Eu(f),r=p,f=s=p=E,r&&(h=wo(),a=n.apply(c,i),s||f||(i=c=null))):s=Nu(e,r)}function u(){s&&Eu(s),f=s=p=E,(v||g!==t)&&(h=wo(),a=n.apply(c,i),s||f||(i=c=null))}function o(){if(i=arguments,l=wo(),c=this,p=v&&(s||!y),false===g)var r=y&&!s;else{f||y||(h=l);var o=g-(l-h),d=0>=o||o>g;d?(f&&(f=Eu(f)),h=l,a=n.apply(c,i)):f||(f=Nu(u,o))}return d&&s?s=Eu(s):s||t===g||(s=Nu(e,t)),r&&(d=true,a=n.apply(c,i)),!d||s||f||(i=c=null),a}var i,f,a,l,c,s,p,h=0,g=false,v=true; +if(!$e(n))throw new vu(P);if(t=0>t?0:t,true===r)var y=true,v=false;else Be(r)&&(y=r.leading,g="maxWait"in r&&Mu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&Eu(s),f&&Eu(f),f=s=p=E},o}function Ce(){var n=arguments,r=n.length-1;if(0>r)return function(){};if(!t(n,$e))throw new vu(P);return function(){for(var t=r,e=n[t].apply(this,arguments);t--;)e=n[t].call(this,e);return e}}function Se(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u); +var o=n.apply(this,arguments);return e.set(u,o),o}if(!$e(n)||t&&!$e(t))throw new vu(P);return r.cache=new Se.Cache,r}function Te(n){var t=ue(arguments,1),r=x(t,Te.placeholder);return Ur(n,W,null,t,r)}function Ne(n){var t=ue(arguments,1),r=x(t,Ne.placeholder);return Ur(n,F,null,t,r)}function We(n){return qr(n&&typeof n=="object"?n.length:E)&&xu.call(n)==gt||false}function Fe(n){return n&&typeof n=="object"&&1===n.nodeType&&-1t||null==n||!zu(t))return r; +n=gu(n);do t%2&&(r+=n),t=Ou(t/2),n+=n;while(t);return r}function Ge(n,t,r){return(n=null==n?"":gu(n))?(r?Mr(n,t,r):null==t)?n.slice(j(n),A(n)+1):(t=gu(t),n.slice(p(n,t),h(n,t)+1)):n}function Je(n,t,r){return n=null!=n&&gu(n),r&&Mr(n,t,r)&&(t=null),n&&n.match(t||st)||[]}function Xe(n){try{return n()}catch(t){return Ue(t)?t:au(t)}}function He(n,t,r){return r&&Mr(n,t,r)&&(t=null),Xt(n,t)}function Qe(n){return function(){return n}}function nu(n){return n}function tu(n){var t=vo(n),r=t.length;if(1==r){var e=t[0],u=n[e]; +if(Pr(u))return function(n){return null!=n&&u===n[e]&&bu.call(n,e)}}for(var o=r,i=iu(r),f=iu(r);o--;){var u=n[t[o]],a=Pr(u);i[o]=a?u:Ht(u,true,Ir),f[o]=a}return function(n){if(o=r,null==n)return!o;for(;o--;)if(f[o]?i[o]!==n[t[o]]:!bu.call(n,t[o]))return false;for(o=r;o--;)if(f[o]?!bu.call(n,t[o]):!hr(i[o],n[t[o]],null,true))return false;return true}}function ru(n,t,r){var e=true,u=Be(t),o=null==r,i=o&&u&&vo(t),f=i&&pr(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=pr(t,vo(t))),false===r?e=false:Be(r)&&"chain"in r&&(e=r.chain),r=-1,u=$e(n); +for(o=f.length;++r=L)return r}else n=0;return ro(r,e)}}(),io=Or(function(n,t,r){bu.call(n,r)?++n[r]:n[r]=1}),fo=Or(function(n,t,r){bu.call(n,r)?n[r].push(t):n[r]=[t]}),ao=Or(function(n,t,r){n[r]=t}),lo=Or(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),co=Ur(Ae,W,null,[2]),so=Lu||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&xu.call(n)==vt||false +};to.dom||(Fe=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!ho(n)||false});var po=Ku||function(n){return typeof n=="number"&&zu(n)};($e(/x/)||Fu&&!$e(Fu))&&($e=function(n){return xu.call(n)==_t});var ho=Ru?function(n){if(!n||xu.call(n)!=wt)return false;var t=n.valueOf,r=Le(t)&&(r=Ru(t))&&Ru(r);return r?n==r||Ru(n)==r:Zr(n)}:Zr,go=Rr(Gt),vo=Du?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},$t.assign=go,$t.at=function(n){return(!n||qr(n.length))&&(n=Jr(n)),Jt(n,ir(arguments,false,false,1))},$t.before=Ae,$t.bind=Ie,$t.bindAll=function(n){for(var t=n,r=1(s?qt(s,i):u(c,i))){for(t=r;--t;){var p=e[t];if(0>(p?qt(p,i):u(n[t],i)))continue n}s&&s.push(i),c.push(i)}return c},$t.invert=function(n,t,r){r&&Mr(n,t,r)&&(t=null),r=-1;for(var e=vo(n),u=e.length,o={};++rt?0:t)},$t.takeRight=function(n,t,r){return(r?Mr(n,t,r):null==t)&&(t=1),t=n?n.length-(+t||0):0,ue(n,0>t?0:t) +},$t.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=$r(t,r,3);e--&&t(n[e],e,n););return ue(n,e+1)},$t.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=$r(t,r,3);++en||!zu(n))return[];t=Xt(t,r,1),r=-1;for(var e=iu(qu(n,Ju));++rr?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},$t.escape=function(n){return(n=null==n?"":gu(n))&&(X.lastIndex=0,X.test(n))?n.replace(X,d):n},$t.escapeRegExp=Ye,$t.every=pe,$t.find=ge,$t.findIndex=ne,$t.findKey=function(n,t,r){return t=$r(t,r,3),or(n,t,cr,true) +},$t.findLast=function(n,t,r){return t=$r(t,r,3),or(n,t,rr)},$t.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=$r(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},$t.findLastKey=function(n,t,r){return t=$r(t,r,3),or(n,t,sr,true)},$t.findWhere=function(n,t){return ge(n,tu(t))},$t.first=te,$t.has=function(n,t){return n?bu.call(n,t):false},$t.identity=nu,$t.includes=se,$t.indexOf=re,$t.isArguments=We,$t.isArray=so,$t.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&xu.call(n)==yt||false +},$t.isDate=function(n){return n&&typeof n=="object"&&xu.call(n)==dt||false},$t.isElement=Fe,$t.isEmpty=function(n){if(null==n)return true;var t=n.length;return qr(t)&&(so(n)||Me(n)||We(n)||typeof n=="object"&&$e(n.splice))?!t:!vo(n).length},$t.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Xt(r,e,3),!r&&Pr(n)&&Pr(t)?n===t:hr(n,t,r)},$t.isError=Ue,$t.isFinite=po,$t.isFunction=$e,$t.isNaN=function(n){return ze(n)&&n!=+n},$t.isNative=Le,$t.isNull=function(n){return null===n},$t.isNumber=ze,$t.isObject=Be,$t.isPlainObject=ho,$t.isRegExp=De,$t.isString=Me,$t.isUndefined=function(n){return typeof n=="undefined" +},$t.kebabCase=_o,$t.last=function(n){var t=n?n.length:0;return t?n[t-1]:E},$t.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?Mu(e+r,0):qu(r||0,e-1))+1;else if(r)return u=ie(n,t)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return _(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},$t.max=me,$t.min=function(n,t,r){r&&Mr(n,t,r)&&(t=null);var e=null==t,u=e&&so(n),o=!u&&Me(n);if(e&&!o)return Kt(u?n:Jr(n));var i=Gu,f=i;return t=e&&o?s:$r(t,r,3),tr(n,function(n,r,e){r=t(n,r,e),(rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},$t.template=function(n,t,r){var e=$t.templateSettings;r&&Mr(n,t,r)&&(t=r=null),n=gu(null==n?"":n),t=go({},r||t,e,Zt),r=go({},t.imports,e.imports,Zt); +var u,o,i=vo(r),f=Ke(r),a=0;r=t.interpolate||ft;var l="__p+='";if(r=hu((t.escape||ft).source+"|"+r.source+"|"+(r===nt?tt:ft).source+"|"+(t.evaluate||ft).source+"|$","g"),n.replace(r,function(t,r,e,i,f,c){return e||(e=i),l+=n.slice(a,c).replace(ct,m),r&&(u=true,l+="'+__e("+r+")+'"),f&&(o=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(o?l.replace(Y,""):l).replace(Z,"$1").replace(G,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Xe(function(){return lu(i,"return "+l).apply(E,f) +}),t.source=l,Ue(t))throw t;return t},$t.trim=Ge,$t.trimLeft=function(n,t,r){return(n=null==n?"":gu(n))?(r?Mr(n,t,r):null==t)?n.slice(j(n)):(t=gu(t),n.slice(p(n,t))):n},$t.trimRight=function(n,t,r){return(n=null==n?"":gu(n))?(r?Mr(n,t,r):null==t)?n.slice(0,A(n)+1):(t=gu(t),n.slice(0,h(n,t)+1)):n},$t.trunc=function(n,t,r){r&&Mr(n,t,r)&&(t=null);var e=$;if(r=B,Be(t)){var u="separator"in t?t.separator:u,e="length"in t?+t.length||0:e;r="omission"in t?gu(t.omission):r}else null!=t&&(e=+t||0);if(n=null==n?"":gu(n),e>=n.length)return n; +if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==u)return t+r;if(De(u)){if(n.slice(e).search(u)){var o,i=n.slice(0,e);for(u.global||(u=hu(u.source,(rt.exec(u)||"")+"g")),u.lastIndex=0;n=u.exec(i);)o=n.index;t=t.slice(0,null==o?e:o)}}else n.indexOf(u,e)!=e&&(u=t.lastIndexOf(u),-1t?0:+t||0,n.length),n)},$t.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return $t.sample(t,n)}):$t.sample(this.value())},$t.VERSION=O,n("bind bindKey curry curryRight partial partialRight".split(" "),function(n){$t[n].placeholder=$t}),n(["filter","map","takeWhile"],function(n,t){var r=t==D; +Lt.prototype[n]=function(n,e){n=$r(n,e,3);var u=this.clone(),o=u.filtered,i=u.iteratees||(u.iteratees=[]);return u.filtered=o||r||t==q&&0>u.dir,i.push({iteratee:n,type:t}),u}}),n(["drop","take"],function(n,t){var r=n+"Count",e=n+"While";Lt.prototype[n]=function(e){e=null==e?1:Mu(+e||0,0);var u=this.clone();if(u.filtered){var o=u[r];u[r]=t?qu(o,e):o+e}else(u.views||(u.views=[])).push({size:e,type:n+(0>u.dir?"Right":"")});return u},Lt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse() +},Lt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),n(["first","last"],function(n,t){var r="take"+(t?"Right":"");Lt.prototype[n]=function(){return this[r](1).value()[0]}}),n(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Lt.prototype[n]=function(){return this[r](1)}}),n(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?tu:ou;Lt.prototype[n]=function(n){return this[r](e(n))}}),Lt.prototype.dropWhile=function(n,t){n=$r(n,t,3);var r,e,u=0>this.dir; +return this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))})},Lt.prototype.reject=function(n,t){return n=$r(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Lt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},cr(Lt.prototype,function(n,t){var r=/^(?:first|last)$/.test(t);$t.prototype[t]=function(){function e(n){return n=[n],Cu.apply(n,o),$t[t].apply($t,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Lt,l=a&&!f; +return r&&!i?l?n.call(u):$t[t](this.value()):a||so(u)?(u=n.apply(l?u:new Lt(this),o),r||!f&&!u.actions||(u.actions||(u.actions=[])).push({args:[e],object:$t,name:"thru"}),new Bt(u,i)):this.thru(e)}}),n("concat join pop push shift sort splice unshift".split(" "),function(n){var t=yu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);$t.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)}) +}}),Lt.prototype.clone=function(){var n=this.actions,t=this.iteratees,r=this.views,e=new Lt(this.wrapped);return e.actions=n?l(n):null,e.dir=this.dir,e.dropCount=this.dropCount,e.filtered=this.filtered,e.iteratees=t?l(t):null,e.takeCount=this.takeCount,e.views=r?l(r):null,e},Lt.prototype.reverse=function(){var n=this.filtered,t=n?new Lt(this):this.clone();return t.dir=-1*this.dir,t.filtered=n,t},Lt.prototype.value=function(){var n=this.wrapped.value();if(!so(n))return jr(n,this.actions);var t,r=this.dir,e=0>r,u=n.length; +t=u;for(var o=this.views,i=0,f=-1,a=o?o.length:0;++f"'`]/g,H=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,nt=/<%=([\s\S]+?)%>/g,tt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,et=/^\s*function[ \n\r\t]+\w/,ut=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,it=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ft=/($^)/,at=/[.*+?^${}()|[\]\/\\]/g,lt=/\bthis\b/,ct=/['\n\r\u2028\u2029\\]/g,st=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),pt=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",ht="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),gt="[object Arguments]",vt="[object Array]",yt="[object Boolean]",dt="[object Date]",mt="[object Error]",_t="[object Function]",bt="[object Number]",wt="[object Object]",xt="[object RegExp]",jt="[object String]",At="[object ArrayBuffer]",It="[object Float32Array]",kt="[object Float64Array]",Et="[object Int8Array]",Ot="[object Int16Array]",Rt="[object Int32Array]",Ct="[object Uint8Array]",St="[object Uint8ClampedArray]",Tt="[object Uint16Array]",Nt="[object Uint32Array]",Wt={}; +Wt[gt]=Wt[vt]=Wt[It]=Wt[kt]=Wt[Et]=Wt[Ot]=Wt[Rt]=Wt[Ct]=Wt[St]=Wt[Tt]=Wt[Nt]=true,Wt[At]=Wt[yt]=Wt[dt]=Wt[mt]=Wt[_t]=Wt["[object Map]"]=Wt[bt]=Wt[wt]=Wt[xt]=Wt["[object Set]"]=Wt[jt]=Wt["[object WeakMap]"]=false;var Ft={};Ft[gt]=Ft[vt]=Ft[At]=Ft[yt]=Ft[dt]=Ft[It]=Ft[kt]=Ft[Et]=Ft[Ot]=Ft[Rt]=Ft[bt]=Ft[wt]=Ft[xt]=Ft[jt]=Ft[Ct]=Ft[St]=Ft[Tt]=Ft[Nt]=true,Ft[mt]=Ft[_t]=Ft["[object Map]"]=Ft["[object Set]"]=Ft["[object WeakMap]"]=false;var Ut={leading:false,maxWait:0,trailing:false},$t={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Bt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Lt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},zt={"function":true,object:true},Dt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mt=zt[typeof window]&&window!==(this&&this.window)?window:this,qt=zt[typeof exports]&&exports&&!exports.nodeType&&exports,Pt=zt[typeof module]&&module&&!module.nodeType&&module,Kt=qt&&Pt&&typeof global=="object"&&global; +!Kt||Kt.global!==Kt&&Kt.window!==Kt&&Kt.self!==Kt||(Mt=Kt);var Vt=Pt&&Pt.exports===qt&&qt,Yt=k();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Mt._=Yt, define(function(){return Yt})):qt&&Pt?Vt?(Pt.exports=Yt)._=Yt:qt._=Yt:Mt._=Yt}).call(this); \ No newline at end of file