diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index c020f04d1..73d98faad 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -24,6 +24,10 @@ PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64; + /** Used to detect when a function becomes hot */ + var HOT_COUNT = 150, + HOT_SPAN = 16; + /** Used as the property name for wrapper metadata */ var EXPANDO = '__lodash_' + VERSION.replace(/[-.]/g, '_') + '__'; @@ -122,7 +126,8 @@ 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'window', 'WinRTError' + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + 'window', 'WinRTError' ]; /** Used to fix the JScript `[[DontEnum]]` bug */ @@ -208,7 +213,7 @@ /** * Used to convert characters to HTML entities. * - * Note: Though the ">" character is escaped for symmetry, characters like + * **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' article](http://mathiasbynens.be/notes/ambiguous-ampersands) @@ -351,16 +356,37 @@ */ function baseIndexOf(array, value, fromIndex) { var index = (fromIndex || 0) - 1, - length = array ? array.length : 0; + length = array ? array.length : 0, + isReflexive = value === value; while (++index < length) { - if (array[index] === value) { + var other = array[index]; + if ((isReflexive ? other === value : other !== other)) { return index; } } return -1; } + /** + * The base implementation of `_.slice` without support for `start` and `end` + * arguments. + * + * @private + * @param {Array} array The array to slice. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array) { + var index = -1, + length = array ? array.length : 0, + result = Array(length); + + while (++index < length) { + result[index] = array[index]; + } + return result; + } + /** * An implementation of `_.contains` for cache objects that mimics the return * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. @@ -399,7 +425,7 @@ var index = -1, length = string.length; - while (++index < length && chars.indexOf(string.charAt(index)) > -1) { } + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} return index; } @@ -415,7 +441,7 @@ function charsRightIndex(string, chars) { var index = string.length; - while (index-- && chars.indexOf(string.charAt(index)) > -1) { } + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} return index; } @@ -519,19 +545,6 @@ return '\\' + stringEscapes[chr]; } - /** - * Checks if `value` is a DOM node in IE < 9. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM node, else `false`. - */ - function isNode(value) { - // IE < 9 presents DOM nodes as `Object` objects except they have `toString` - // methods that are `typeof` "string" and still can coerce nodes to strings - return typeof value.toString != 'function' && typeof (value + '') == 'string'; - } - /** * Used by `_.trimmedLeftIndex` and `_.trimmedRightIndex` to determine if a * character code is whitespace. @@ -557,7 +570,7 @@ var index = -1, length = string.length; - while (++index < length && isWhitespace(string.charCodeAt(index))) { } + while (++index < length && isWhitespace(string.charCodeAt(index))) {} return index; } @@ -572,7 +585,7 @@ function trimmedRightIndex(string) { var index = string.length; - while (index-- && isWhitespace(string.charCodeAt(index))) { } + while (index-- && isWhitespace(string.charCodeAt(index))) {} return index; } @@ -647,6 +660,9 @@ /** Used to resolve the decompiled source of functions */ var fnToString = Function.prototype.toString; + /** Used to check objects for own properties */ + var hasOwnProperty = objectProto.hasOwnProperty; + /** Used to restore the original `_` reference in `_.noConflict` */ var oldDash = context._; @@ -666,13 +682,13 @@ clearTimeout = context.clearTimeout, floor = Math.floor, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, - hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, - Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array; + Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, + WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; /** Used to clone array buffers */ var Float64Array = (function() { @@ -682,7 +698,7 @@ try { var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func; - } catch(e) { } + } catch(e) {} return result; }()); @@ -693,13 +709,12 @@ var o = {}, func = isNative(func = Object.defineProperty) && func, result = func(o, o, o) && func; - } catch(e) { } + } catch(e) {} return result; }()); /* Native method references for those with the same name as other `lodash` methods */ - var nativeContains = isNative(nativeContains = stringProto.contains) && nativeContains, - nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, + var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, @@ -713,6 +728,9 @@ /** Used as the size, in bytes, of each Float64Array element */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; + /** Used to store function metadata */ + var metaMap = WeakMap && new WeakMap; + /** Used to lookup a built-in constructor by [[Class]] */ var ctorByClass = {}; ctorByClass[float32Class] = context.Float32Array; @@ -772,17 +790,17 @@ * * The non-chainable wrapper functions are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `contains`, - * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, isDate`, + * `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`, - * `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`, and `value` + * `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`, and `value` * * The wrapper function `sample` will return a wrapped value when `n` is * provided, otherwise it will return an unwrapped value. @@ -852,8 +870,6 @@ Ctor.prototype = { 'valueOf': 1, 'y': 1 }; for (var key in new Ctor) { props.push(key); } - for (var argsKey in arguments) { } - for (var strKey in 'x') { } /** * Detect if the `[[Class]]` of `arguments` objects is resolvable @@ -912,7 +928,7 @@ * @memberOf _.support * @type boolean */ - support.nonEnumStrings = strKey != '0'; + support.nonEnumStrings = !propertyIsEnumerable.call('x', 0); /** * Detect if properties shadowing those on `Object.prototype` are @@ -975,19 +991,25 @@ } /** - * Detect if the `[[Class]]` of DOM nodes is resolvable (all but IE < 9) - * and that the JS engine errors when attempting to coerce an object to a - * string without a `toString` function. + * Detect if the host objects are detectable (IE < 9). * * @memberOf _.support * @type boolean */ try { - support.nodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + '')); + support.hostObject = !({ 'toString': 0 } + ''); } catch(e) { - support.nodeClass = true; + support.hostObject = false; } + /** + * Detect if the `[[Class]]` of DOM nodes is resolvable (all but IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.nodeClass = !(toString.call(document) == objectClass && support.hostObject); + /** * Detect if `arguments` object indexes are non-enumerable. * @@ -1001,7 +1023,7 @@ * @type boolean */ try { - support.nonEnumArgs = !(hasOwnProperty.call(arguments, 1) && propertyIsEnumerable.call(arguments, 1)); + support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1); } catch(e) { support.nonEnumArgs = true; } @@ -1076,15 +1098,15 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEach(array, iterator) { + function arrayEach(array, iteratee) { var index = -1, length = array.length; while (++index < length) { - if (iterator(array[index], index, array) === false) { + if (iteratee(array[index], index, array) === false) { break; } } @@ -1097,14 +1119,14 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEachRight(array, iterator) { + function arrayEachRight(array, iteratee) { var length = array.length; while (length--) { - if (iterator(array[length], length, array) === false) { + if (iteratee(array[length], length, array) === false) { break; } } @@ -1139,16 +1161,16 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function arrayMap(array, iterator) { + function arrayMap(array, iteratee) { var index = -1, length = array.length, result = Array(length); while (++index < length) { - result[index] = iterator(array[index], index, array); + result[index] = iteratee(array[index], index, array); } return result; } @@ -1165,12 +1187,13 @@ function arrayFilter(array, predicate) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { - result.push(value); + result[++resIndex] = value; } } return result; @@ -1182,13 +1205,13 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iterator, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1, length = array.length; @@ -1196,7 +1219,7 @@ accumulator = array[++index]; } while (++index < length) { - accumulator = iterator(accumulator, array[index], index, array); + accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } @@ -1207,20 +1230,20 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iterator, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; if (initFromArray && length) { accumulator = array[--length]; } while (length--) { - accumulator = iterator(accumulator, array[length], length, array); + accumulator = iteratee(accumulator, array[length], length, array); } return accumulator; } @@ -1264,7 +1287,7 @@ /** * Used by `_.template` to customize its `_.assign` use. * - * Note: This method is like `assignDefaults` except that it ignores + * **Note:** This method is like `assignDefaults` except that it ignores * inherited property values when checking if a property is `undefined`. * * @private @@ -1319,7 +1342,7 @@ while (++index < length) { var key = methodNames[index]; - object[key] = createWrapper([object[key], BIND_FLAG, null, object]); + object[key] = createWrapper(object[key], BIND_FLAG, null, object); } return object; } @@ -1341,7 +1364,7 @@ if (typeof thisArg == 'undefined') { return func; } - var data = func[EXPANDO]; + var data = getData(func); if (typeof data == 'undefined') { if (support.funcNames) { data = !func.name; @@ -1355,7 +1378,7 @@ if (!data) { // checks if `func` references the `this` keyword and stores the result data = reThis.test(source) || isNative(func); - setData(func, data); + baseSetData(func, data); } } } @@ -1405,79 +1428,15 @@ if (typeof result != 'undefined') { return result; } - var isArr = isArray(value), - isShallow = !isDeep; - + var isArr = isArray(value); + result = value; if (isArr) { - result = isShallow ? slice(value) : value.constructor(value.length); - - // add array properties assigned by `RegExp#exec` - if (typeof value[0] == 'string' && hasOwnProperty.call(value, 'index')) { - result.index = value.index; - result.input = value.input; - } - if (isShallow) { - return result; - } + result = initArrayClone(value, isDeep); + } else if (isObject(value)) { + result = initObjectClone(value, isDeep); + value = (isDeep && toString.call(result) == objectClass) ? value : result; } - else { - if (!isObject(value)) { - return value; - } - var className = toString.call(value); - if (!cloneableClasses[className] || (!support.nodeClass && isNode(value))) { - return value; - } - var isArgs = className == argsClass || (!support.argsClass && isArguments(value)), - isObj = !isArgs && className == objectClass; - - if (isShallow && (isArgs || isObj)) { - result = baseAssign({}, value); - if (isObj) { - return result; - } - } - var Ctor = value.constructor; - if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { - Ctor = Object; - } - if (isDeep && (isArgs || isObj)) { - result = new Ctor; - } - else { - switch (className) { - case arrayBufferClass: - return cloneBuffer(value); - - case boolClass: - case dateClass: - return new Ctor(+value); - - 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 - if (Ctor instanceof Ctor) { - Ctor = ctorByClass[className]; - } - var buffer = value.buffer; - return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, value.byteOffset, value.length); - - case numberClass: - case stringClass: - return new Ctor(value); - - case regexpClass: - result = Ctor(value.source, reFlags.exec(value)); - result.lastIndex = value.lastIndex; - return result; - } - } - } - if (isArgs) { - result.length = value.length; - } - if (isShallow) { + if (!isDeep || result === value) { return result; } // check for circular references and return corresponding clone @@ -1532,85 +1491,6 @@ }()); } - /** - * The base implementation of `createWrapper` which creates the wrapper and - * sets its metadata. - * - * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new function. - */ - function baseCreateWrapper(data) { - var bitmask = data[1]; - if (bitmask == BIND_FLAG) { - return setData(createBindWrapper(data), data); - } - var partialHolders = data[5]; - if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { - return setData(createPartialWrapper(data), data); - } - var func = data[0], - arity = data[2], - thisArg = data[3], - partialArgs = data[4], - partialRightArgs = data[6], - partialRightHolders = data[7]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isCurry = bitmask & CURRY_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG, - isCurryBound = bitmask & CURRY_BOUND_FLAG; - - var Ctor = !isBindKey && createCtorWrapper(func), - key = func; - - var wrapper = function() { - var length = arguments.length, - index = length, - args = Array(length); - - while (index--) { - args[index] = arguments[index]; - } - if (partialArgs) { - args = composeArgs(partialArgs, partialHolders, args); - } - if (partialRightArgs) { - args = composeArgsRight(partialRightArgs, partialRightHolders, args); - } - if (isCurry || isCurryRight) { - var placeholder = wrapper.placeholder, - newPartialHolders = replaceHolders(args, placeholder); - - length -= newPartialHolders.length; - - if (length < arity) { - bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); - - if (!isCurryBound) { - bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); - } - var newData = [func, bitmask, nativeMax(arity - length, 0), thisArg, null, null]; - newData[isCurry ? 4 : 6] = args; - newData[isCurry ? 5 : 7] = newPartialHolders; - - var result = baseCreateWrapper(newData); - result.placeholder = placeholder; - return result; - } - } - var thisBinding = isBind ? thisArg : this; - if (isBindKey) { - func = thisBinding[key]; - } - return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); - }; - - return setData(wrapper, data); - } - /** * The base implementation of `_.curry` and `_.curryRight` which handles * resolving the default arity of `func`. @@ -1623,9 +1503,9 @@ */ function baseCurry(func, bitmask, arity) { if (typeof arity != 'number') { - arity = +arity || (func ? func.length : 0); + arity = arity == null ? (func ? func.length : 0) : nativeMax(+arity || 0, 0); } - return createWrapper([func, bitmask, arity]); + return createWrapper(func, bitmask, arity); } /** @@ -1658,7 +1538,7 @@ while (++index < length) { var value = array[index]; - if (isCommon) { + if (isCommon && value === value) { var valuesIndex = valuesLength; while (valuesIndex--) { if (values[valuesIndex] === value) { @@ -1680,19 +1560,19 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iterator) { + function baseEach(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwn(collection, iterator); + return baseForOwn(collection, iteratee); } var index = -1, iterable = toIterable(collection); while (++index < length) { - if (iterator(iterable[index], index, iterable) === false) { + if (iteratee(iterable[index], index, iterable) === false) { break; } } @@ -1705,17 +1585,17 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iterator) { + function baseEachRight(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwnRight(collection, iterator); + return baseForOwnRight(collection, iteratee); } var iterable = toIterable(collection); while (length--) { - if (iterator(iterable[length], length, iterable) === false) { + if (iteratee(iterable[length], length, iterable) === false) { break; } } @@ -1829,24 +1709,24 @@ /** * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` executing `iterator` for + * over `object` properties returned by `keysFunc` executing `iteratee` for * each property. Iterator functions may exit iteration early by explicitly * returning `false`. * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iterator, keysFunc) { + function baseFor(object, iteratee, keysFunc) { var index = -1, props = keysFunc(object), length = props.length; while (++index < length) { var key = props[index]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1859,17 +1739,17 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iterator, keysFunc) { + function baseForRight(object, iteratee, keysFunc) { var props = keysFunc(object), length = props.length; while (length--) { var key = props[length]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1882,11 +1762,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForIn(object, iterator) { - return baseFor(object, iterator, keysIn); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); } /** @@ -1895,11 +1775,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwn(object, iterator) { - return baseFor(object, iterator, keys); + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } /** @@ -1908,32 +1788,32 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwnRight(object, iterator) { - return baseForRight(object, iterator, keys); + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); } /** - * The base implementation of `_.functions` which creates an array of function - * property names from those returned by `keysFunc`. + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from those provided. * * @private * @param {Object} object The object to inspect. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Array} Returns the new sorted array of property names. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the new array of filtered property names. */ - function baseFunctions(object, keysFunc) { + function baseFunctions(object, props) { var index = -1, - props = keysFunc(object), length = props.length, + resIndex = -1, result = []; while (++index < length) { var key = props[index]; if (isFunction(object[key])) { - result.push(key); + result[++resIndex] = key; } } return result; @@ -1995,7 +1875,7 @@ return false; } } - else if (isErr || (valClass == objectClass && (support.nodeClass || !(isNode(value) || isNode(other))))) { + else if (isErr || (valClass == objectClass && (support.nodeClass || !(isHostObject(value) || isHostObject(other))))) { // unwrap any `lodash` wrapped values var valWrapped = hasOwnProperty.call(value, '__wrapped__'), othWrapped = hasOwnProperty.call(other, '__wrapped__'); @@ -2061,7 +1941,7 @@ return (value != +value) ? other != +other // but treat `-0` vs. `+0` as not equal - : (value == 0 ? (1 / value == 1 / other) : value == +other); + : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); case regexpClass: case stringClass: @@ -2164,14 +2044,14 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function baseMap(collection, iterator) { + function baseMap(collection, iteratee) { var result = []; baseEach(collection, function(value, key, collection) { - result.push(iterator(value, key, collection)); + result.push(iteratee(value, key, collection)); }); return result; } @@ -2254,51 +2134,14 @@ */ function basePartial(func, bitmask, args, holders, thisArg) { if (func) { - var data = func[EXPANDO], + var data = getData(func), arity = data ? data[2] : func.length; arity -= args.length; } - var isPartial = bitmask & PARTIAL_FLAG, - newData = [func, bitmask, arity, thisArg, null, null]; - - newData[isPartial ? 4 : 6] = args; - newData[isPartial ? 5 : 7] = holders; - return createWrapper(newData); - } - - /** - * The base implementation of `_.pick` without support for `this` binding - * and individual property name arguments. - * - * @private - * @param {Object} object The source object. - * @param {Function|string[]} predicate The function called per iteration or - * property names to pick. - * @returns {Object} Returns the new object. - */ - function basePick(object, predicate) { - var result = {}; - - if (typeof predicate == 'function') { - baseForIn(object, function(value, key, object) { - if (predicate(value, key, object)) { - result[key] = value; - } - }); - return result; - } - var index = -1, - props = predicate, - length = props.length; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - return result; + return (bitmask & PARTIAL_FLAG) + ? createWrapper(func, bitmask, arity, thisArg, args, holders) + : createWrapper(func, bitmask, arity, thisArg, null, null, args, holders); } /** @@ -2345,22 +2188,44 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} accumulator The initial value. * @param {boolean} initFromCollection Specify using the first or last element * of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iterator, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { eachFunc(collection, function(value, index, collection) { accumulator = initFromCollection ? (initFromCollection = false, value) - : iterator(accumulator, value, index, collection) + : iteratee(accumulator, value, index, collection) }); return accumulator; } + /** + * The base implementation of `setData` without support for hot loop detection. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + function baseSetData(func, data) { + metaMap.set(func, data); + return func; + } + // fallback for environments without `WeakMap` + if (!WeakMap) { + baseSetData = !defineProperty ? identity : function(func, value) { + descriptor.value = value; + defineProperty(func, EXPANDO, descriptor); + descriptor.value = null; + return func; + }; + } + /** * The base implementation of `_.some` without support for callback shorthands * or `this` binding. @@ -2388,24 +2253,24 @@ * @private * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {boolean} [retHighest=false] Specify returning the highest, instead * of the lowest, index at which a value should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ - function baseSortedIndex(array, value, iterator, retHighest) { + function baseSortedIndex(array, value, iteratee, retHighest) { var low = 0, high = array ? array.length : low; - value = iterator(value); + value = iteratee(value); var hintNum = typeof value == 'number' || (value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number'); while (low < high) { var mid = (low + high) >>> 1, - computed = iterator(array[mid]), - setLow = retHighest ? computed <= value : computed < value; + computed = iteratee(array[mid]), + setLow = retHighest ? (computed <= value) : (computed < value); if (hintNum && typeof computed != 'undefined') { computed = +computed; @@ -2426,10 +2291,10 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function baseUniq(array, iterator) { + function baseUniq(array, iteratee) { var index = -1, indexOf = getIndexOf(), length = array.length, @@ -2442,27 +2307,27 @@ var seen = createCache(); indexOf = cacheIndexOf; } else { - seen = iterator ? [] : result; + seen = iteratee ? [] : result; } outer: while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; - if (isCommon) { + if (isCommon && value === value) { var seenIndex = seen.length; while (seenIndex--) { if (seen[seenIndex] === computed) { continue outer; } } - if (iterator) { + if (iteratee) { seen.push(computed); } result.push(value); } else if (indexOf(seen, computed) < 0) { - if (iterator || isLarge) { + if (iteratee || isLarge) { seen.push(computed); } result.push(value); @@ -2493,6 +2358,36 @@ return result; } + /** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function bufferClone(buffer) { + return bufferSlice.call(buffer, 0); + } + if (!bufferSlice) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` + bufferClone = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + var byteLength = buffer.byteLength, + floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, + offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, + result = new ArrayBuffer(byteLength); + + if (floatLength) { + var view = new Float64Array(result, 0, floatLength); + view.set(new Float64Array(buffer, 0, floatLength)); + } + if (byteLength != offset) { + view = new Uint8Array(result, offset); + view.set(new Uint8Array(buffer, offset)); + } + return result; + }; + } + /** * Creates an array that is the composition of partially applied arguments, * placeholders, and provided arguments into a single array of arguments. @@ -2558,7 +2453,7 @@ /** * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection - * through `iterator`. The given setter function sets the keys and values of + * through `iteratee`. The given setter function sets the keys and values of * the accumulator object. If `initializer` is provided it is used to initialize * the accumulator object. * @@ -2568,9 +2463,9 @@ * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function(collection, iterator, thisArg) { + return function(collection, iteratee, thisArg) { var result = initializer ? initializer() : {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); if (isArray(collection)) { var index = -1, @@ -2578,11 +2473,11 @@ while (++index < length) { var value = collection[index]; - setter(result, value, iterator(value, index, collection), collection); + setter(result, value, iteratee(value, index, collection), collection); } } else { baseEach(collection, function(value, key, collection) { - setter(result, value, iterator(value, key, collection), collection); + setter(result, value, iteratee(value, key, collection), collection); }); } return result; @@ -2598,44 +2493,43 @@ * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { - return function(object) { - var args = arguments, - length = args.length; + return function() { + var length = arguments.length, + object = arguments[0]; if (object == null || length < 2) { return object; } // enables use as a callback for functions like `_.reduce` - var type = typeof args[2]; - if ((type == 'number' || type == 'string') && args[3] && args[3][args[2]] === args[1]) { + var type = typeof arguments[2]; + if ((type == 'number' || type == 'string') && arguments[3] && arguments[3][arguments[2]] === arguments[1]) { length = 2; } // juggle arguments - if (length > 3 && typeof args[length - 2] == 'function') { - var customizer = baseCallback(args[--length - 1], args[length--], 5); - } else if (length > 2 && typeof args[length - 1] == 'function') { - customizer = args[--length]; + 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') { + customizer = arguments[--length]; } var index = 0; while (++index < length) { - assigner(object, args[index], customizer); + assigner(object, arguments[index], customizer); } return object; }; } /** - * Creates a function that invokes the function specified in the metadata - * with its associated `this` binding. + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new bound function. + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. */ - function createBindWrapper(data) { - var func = data[0], - thisArg = data[3], - Ctor = createCtorWrapper(func); + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); function wrapper() { return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments); @@ -2680,6 +2574,77 @@ }; } + /** + * Creates a function that wraps `func` and invokes it with optional `this` + * binding of, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. + * @returns {Function} Returns the new function. + */ + function createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBind = bitmask & BIND_FLAG, + isBindKey = bitmask & BIND_KEY_FLAG, + isCurry = bitmask & CURRY_FLAG, + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + isCurryBound = bitmask & CURRY_BOUND_FLAG; + + var Ctor = !isBindKey && createCtorWrapper(func), + key = func; + + function wrapper() { + var length = arguments.length, + index = length, + args = Array(length); + + while (index--) { + args[index] = arguments[index]; + } + if (partialArgs) { + args = composeArgs(partialArgs, partialHolders, args); + } + if (partialRightArgs) { + args = composeArgsRight(partialRightArgs, partialRightHolders, args); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, + holders = replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + var newArity = nativeMax(arity - length, 0), + newPartialArgs = isCurry ? args : null, + newPartialHolders = isCurry ? holders : null, + newPartialRightArgs = isCurry ? null : args, + newPartialRightHolders = isCurry ? null : holders; + + bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var result = createHybridWrapper(func, bitmask, newArity, thisArg, newPartialArgs, newPartialHolders, newPartialRightArgs, newPartialRightHolders); + result.placeholder = placeholder; + return setData(result, [func, bitmask, newArity, thisArg, newPartialArgs, newPartialHolders, newPartialRightArgs, newPartialRightHolders]); + } + } + var thisBinding = isBind ? thisArg : this; + if (isBindKey) { + func = thisBinding[key]; + } + return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); + } + return wrapper; + } + /** * Creates the pad required for `string` based on the given padding length. * The `chars` string may be truncated if the number of padding characters @@ -2704,25 +2669,25 @@ } /** - * Creates a function that invokes the function specified in the metadata - * with its associated partially applied arguments and optional `this` binding. + * Creates a function that wraps `func` and invokes it with the optional `this` + * binding of `thisArg` and the `partialArgs` prepended to those provided to + * the wrapper. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. + * @param {Function} func The function to partially apply arguments to. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {Array} partialArgs An array of 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(data) { - var func = data[0], - thisArg = data[3], - partialArgs = data[4]; - - var isBind = data[1] & BIND_FLAG, + function createPartialWrapper(func, bitmask, partialArgs, thisArg) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { // avoid `arguments` object use disqualifying optimizations by // converting it to an array before passing it to `composeArgs` - var argsIndex = 0, + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partialArgs.length, @@ -2732,7 +2697,7 @@ args[leftIndex] = partialArgs[leftIndex]; } while (argsLength--) { - args[leftIndex++] = arguments[argsIndex++]; + args[leftIndex++] = arguments[++argsIndex]; } return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args); } @@ -2744,9 +2709,8 @@ * `this` binding and partially applied arguments. * * @private - * @param {Array} data The metadata array. - * @param {Function|string} data[0] The function or method name to reference. - * @param {number} data[1] The bitmask of flags to compose. + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. * The bitmask may be composed of the following flags: * 1 - `_.bind` * 2 - `_.bindKey` @@ -2755,97 +2719,80 @@ * 16 - `_.curry` or `_.curryRight` of a bound function * 32 - `_.partial` * 64 - `_.partialRight` - * @param {number} data[2] The arity of `data[0]`. - * @param {*} [data[3]] The `this` binding of `data[0]`. - * @param {Array} [data[4]] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [data[5]] An array of `data[4]` placeholder indexes. - * @param {Array} [data[6]] An array of arguments to append to those - * provided to the new function. - * @param {Array} [data[7]] An array of `data[6]` placeholder indexes. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. * @returns {Function} Returns the new function. */ - function createWrapper(data) { - var func = data[0], - bitmask = data[1]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isPartial = bitmask & PARTIAL_FLAG, - isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; - + function createWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBindKey = bitmask & BIND_KEY_FLAG; if (!isBindKey && !isFunction(func)) { throw new TypeError(FUNC_ERROR_TEXT); } - var arity = data[2], - partialArgs = data[4], - partialRightArgs = data[6]; - + var isPartial = bitmask & PARTIAL_FLAG; if (isPartial && !partialArgs.length) { + bitmask &= ~PARTIAL_FLAG; isPartial = false; - data[1] = (bitmask &= ~PARTIAL_FLAG); - data[4] = data[5] = partialArgs = null; + partialArgs = partialHolders = null; } + var isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; if (isPartialRight && !partialRightArgs.length) { + bitmask &= ~PARTIAL_RIGHT_FLAG; isPartialRight = false; - data[1] = (bitmask &= ~PARTIAL_RIGHT_FLAG); - data[6] = data[7] = partialRightArgs = null; + partialRightArgs = partialRightHolders = null; } - var funcData = !isBindKey && func[EXPANDO]; - if (funcData && funcData !== true) { - // shallow clone `funcData` - funcData = slice(funcData); + var data = (data = !isBindKey && getData(func)) && data !== true && data; + if (data) { + var funcBitmask = data[1], + funcIsBind = funcBitmask & BIND_FLAG, + isBind = bitmask & BIND_FLAG; - // clone partial left arguments - if (funcData[4]) { - funcData[4] = slice(funcData[4]); - funcData[5] = slice(funcData[5]); + // use metadata `func` and merge bitmasks + func = data[0]; + bitmask |= funcBitmask; + + // use metadata `arity` if not provided + if (arity == null) { + arity = data[2]; } - // clone partial right arguments - if (funcData[6]) { - funcData[6] = slice(funcData[6]); - funcData[7] = slice(funcData[7]); - } - // set arity if provided - if (typeof arity == 'number') { - funcData[2] = arity; - } - // set `thisArg` if not previously bound - var bound = funcData[1] & BIND_FLAG; - if (isBind && !bound) { - funcData[3] = data[3]; + // use metadata `thisArg` if available + if (funcIsBind) { + thisArg = data[3]; } // set if currying a bound function - if (!isBind && bound) { + if (!isBind && funcIsBind) { bitmask |= CURRY_BOUND_FLAG; } // append partial left arguments - if (isPartial) { - var funcPartialArgs = funcData[4]; - if (funcPartialArgs) { - funcPartialArgs = composeArgs(funcPartialArgs, funcData[5], partialArgs); - } - funcData[4] = funcPartialArgs || partialArgs; - funcData[5] = funcPartialArgs ? replaceHolders(funcPartialArgs, PLACEHOLDER) : data[5]; + var funcArgs = data[4]; + if (funcArgs) { + var funcHolders = data[5]; + partialArgs = isPartial ? composeArgs(funcArgs, funcHolders, partialArgs) : baseSlice(funcArgs); + partialHolders = isPartial ? replaceHolders(partialArgs, PLACEHOLDER) : baseSlice(funcHolders); } // prepend partial right arguments - if (isPartialRight) { - var funcPartialRightArgs = funcData[6]; - if (funcPartialRightArgs) { - funcPartialRightArgs = composeArgsRight(funcPartialRightArgs, funcData[7], partialRightArgs); - } - funcData[6] = funcPartialRightArgs || partialRightArgs; - funcData[7] = funcPartialRightArgs ? replaceHolders(funcPartialRightArgs, PLACEHOLDER) : data[7]; + funcArgs = data[6]; + if (funcArgs) { + funcHolders = data[7]; + partialRightArgs = isPartialRight ? composeArgsRight(funcArgs, funcHolders, partialRightArgs) : baseSlice(funcArgs); + partialRightHolders = isPartialRight ? replaceHolders(partialRightArgs, PLACEHOLDER) : baseSlice(funcHolders); } - // merge flags - funcData[1] |= bitmask; - return createWrapper(funcData); } if (arity == null) { arity = isBindKey ? 0 : func.length; } - data[2] = nativeMax(arity, 0); - return baseCreateWrapper(data); + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(func, thisArg); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { + result = createPartialWrapper(func, bitmask, partialArgs, thisArg); + } else { + result = createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders); + } + var setter = data ? baseSetData : setData; + return setter(result, [func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders]); } /** @@ -2860,7 +2807,24 @@ function getCallback(func, thisArg, argCount) { var result = lodash.callback || callback; result = result === callback ? baseCallback : result; - return arguments.length ? result(func, thisArg, argCount) : result; + return argCount ? result(func, thisArg, argCount) : result; + } + + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + function getData(func) { + return metaMap.get(func); + } + // fallback for environments without `WeakMap` + if (!WeakMap) { + getData = !defineProperty ? noop : function(func) { + return func[EXPANDO]; + }; } /** @@ -2878,6 +2842,88 @@ return collection ? result(collection, target, fromIndex) : result; } + /** + * Initializes an array clone. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @returns {*} Returns the initialized clone value. + */ + function initArrayClone(array, isDeep) { + var index = -1, + length = array.length, + result = array.constructor(length); + + if (!isDeep) { + while (++index < length) { + result[index] = array[index]; + } + } + // 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; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @returns {*} Returns the initialized clone value. + */ + function initObjectClone(object, isDeep) { + var className = toString.call(object); + if (!cloneableClasses[className] || (!support.nodeClass && isHostObject(object))) { + return object; + } + var Ctor = object.constructor, + isArgs = className == argsClass || (!support.argsClass && isArguments(object)), + isObj = className == objectClass; + + if (isObj && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { + Ctor = Object; + } + if (isArgs || isObj) { + var result = isDeep ? new Ctor : baseAssign(new Ctor, object); + if (isArgs) { + result.length = object.length; + } + return result; + } + switch (className) { + case arrayBufferClass: + return bufferClone(object); + + case boolClass: + case dateClass: + return new Ctor(+object); + + 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 + if (Ctor instanceof Ctor) { + Ctor = ctorByClass[className]; + } + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberClass: + case stringClass: + return new Ctor(object); + + case regexpClass: + result = Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + /** * Checks if `value` is an array-like object. * @@ -2891,18 +2937,17 @@ } /** - * Checks if `value` is a native function. + * Checks if `value` is a host object in IE < 9. * * @private * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. */ - function isNative(value) { - var type = typeof value; - return type == 'function' - ? reNative.test(fnToString.call(value)) - : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; - } + var isHostObject = support.hostObject ? constant(false) : function(value) { + // 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'; + }; /** * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. @@ -2913,37 +2958,50 @@ * equality comparisons, else `false`. */ function isStrictComparable(value) { - return value === value && (value === 0 ? (1 / value > 0) : !isObject(value)); + return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); } /** - * Creates a clone of the given array buffer. + * A specialized version of `_.pick` that picks `object` properties + * specified by the `props` array. * * @private - * @param {ArrayBuffer} buffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. + * @param {Object} object The source object. + * @param {string[]} props The property names to pick. + * @returns {Object} Returns the new object. */ - function cloneBuffer(buffer) { - return bufferSlice.call(buffer, 0); - } - if (!bufferSlice) { - // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` - cloneBuffer = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { - var byteLength = buffer.byteLength, - floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, - offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, - result = new ArrayBuffer(byteLength); + function pickByArray(object, props) { + var index = -1, + length = props.length, + result = {}; - if (floatLength) { - var view = new Float64Array(result, 0, floatLength); - view.set(new Float64Array(buffer, 0, floatLength)); + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; } - if (byteLength != offset) { - view = new Uint8Array(result, offset); - view.set(new Uint8Array(buffer, offset)); + } + return result; + } + + /** + * A specialized version of `_.pick` that picks `object` properties + * the predicate returns truthy for. + * + * @private + * @param {Object} object The source object. + * @param {Function} predicate The function called per iteration. + * @returns {Object} Returns the new object. + */ + function pickByCallback(object, predicate) { + var result = {}; + + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; } - return result; - }; + }); + return result; } /** @@ -2958,31 +3016,49 @@ function replaceHolders(array, placeholder) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { if (array[index] === placeholder) { array[index] = PLACEHOLDER; - result.push(index); + result[++resIndex] = index; } } return result; } /** - * Sets wrapper metadata on a given function. + * Sets metadata for `func`. + * + * **Note**: If this function becomes hot, i.e. is called a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses. * * @private - * @param {Function} func The function to set data on. - * @param {Array} value The data array to set. + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. * @returns {Function} Returns `func`. */ - var setData = !defineProperty ? identity : function(func, value) { - descriptor.value = value; - defineProperty(func, EXPANDO, descriptor); - descriptor.value = null; - return func; - }; + var setData = (function() { + var count = 0, + lastCalled = 0; + + return function(key, value) { + var stamp = now ? now() : 0, + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count > HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); + }; + }()); /** * A fallback implementation of `_.isPlainObject` which checks if `value` @@ -3002,7 +3078,7 @@ (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, isFunction(Ctor) && !(Ctor instanceof Ctor))) || (!support.argsClass && isArguments(value)) || - (!support.nodeClass && isNode(value))) { + (!support.nodeClass && isHostObject(value))) { return false; } // IE < 9 iterates inherited properties before own properties. If the first @@ -3061,22 +3137,23 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function sortedUniq(array, iterator) { + function sortedUniq(array, iteratee) { var seen, index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (!index || seen !== computed) { seen = computed; - result.push(value); + result[++resIndex] = value; } } return result; @@ -3121,7 +3198,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements split into groups the length of `chunkSize`. + * Creates an array of elements split into groups the length of `size`. * If `collection` can't be split evenly, the final chunk will be the remaining * elements. * @@ -3129,7 +3206,7 @@ * @memberOf _ * @category Array * @param {Array} array The array to process. - * @param {numer} [chunkSize=1] The size of each chunk. + * @param {numer} [size=1] The length of each chunk. * @returns {Array} Returns the new array containing chunks. * @example * @@ -3139,14 +3216,15 @@ * _.chunk(['a', 'b', 'c', 'd'], 3); * // => [['a', 'b', 'c'], ['d']] */ - function chunk(array, chunkSize) { + function chunk(array, size) { var index = 0, length = array ? array.length : 0, + resIndex = -1, result = []; - chunkSize = nativeMax(+chunkSize || 1, 1); + size = typeof size == 'undefined' ? 1 : nativeMax(+size || 1, 1); while (index < length) { - result.push(slice(array, index, (index += chunkSize))); + result[++resIndex] = slice(array, index, (index += size)); } return result; } @@ -3181,8 +3259,12 @@ } /** - * Creates an array excluding all values of the provided arrays using strict - * equality for comparisons, i.e. `===`. + * Creates an array excluding all values of the provided arrays using + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3315,7 +3397,7 @@ index = length; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) { } + while (index-- && predicate(array[index], index, array)) {} return slice(array, 0, index + 1); } @@ -3364,7 +3446,7 @@ length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) { } + while (++index < length && predicate(array[index], index, array)) {} return slice(array, index); } @@ -3549,10 +3631,14 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` - * using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, + * 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. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @category Array @@ -3606,7 +3692,11 @@ /** * Creates an array of unique values present in all provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3714,8 +3804,10 @@ index = sortedLastIndex(array, value) - 1; return (length && array[index] === value) ? index : -1; } + var isReflexive = value === value; while (index--) { - if (array[index] === value) { + var other = array[index]; + if ((isReflexive ? other === value : other !== other)) { return index; } } @@ -3723,10 +3815,14 @@ } /** - * Removes all provided values from `array` using strict equality for - * comparisons, i.e. `===`. + * Removes all provided values from `array` using `SameValueZero` for equality + * comparisons. * - * Note: Unlike `_.without`, this method mutates `array`. + * **Note:** Unlike `_.without`, this method mutates `array`. + * + * `SameValueZero` is like strict equality, e.g. `===`, except that `NaN` matches + * `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3741,20 +3837,18 @@ * console.log(array); * // => [1, 1] */ - function pull(array) { - var argsIndex = 0, - argsLength = arguments.length, - length = array ? array.length : 0; + function pull() { + var array = arguments[0], + index = 0, + indexOf = getIndexOf(), + length = arguments.length; - while (++argsIndex < argsLength) { - var index = -1, - value = arguments[argsIndex]; + while (++index < length) { + var fromIndex = 0, + value = arguments[index]; - while (++index < length) { - if (array[index] === value) { - splice.call(array, index--, 1); - length--; - } + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); } } return array; @@ -3765,7 +3859,7 @@ * returns an array of the removed elements. Indexes may be specified as an * array of indexes or as individual arguments. * - * Note: Unlike `_.at`, this method mutates `array`. + * **Note:** Unlike `_.at`, this method mutates `array`. * * @static * @memberOf _ @@ -3801,7 +3895,7 @@ * returns `true` for elements that have the properties of the given object, * else `false`. * - * Note: Unlike `_.filter`, this method mutates `array`. + * **Note:** Unlike `_.filter`, this method mutates `array`. * * @static * @memberOf _ @@ -3861,7 +3955,7 @@ /** * Slices `array` from the `start` index up to, but not including, the `end` index. * - * Note: This function is used instead of `Array#slice` to support node lists + * **Note:** This function is used instead of `Array#slice` to support node lists * in IE < 9 and to ensure dense arrays are returned. * * @static @@ -3884,6 +3978,9 @@ if (end < 0) { end += length; } + if (end && end == length && !start) { + return baseSlice(array); + } length = start > end ? 0 : (end - start); var result = Array(length); @@ -3896,14 +3993,14 @@ /** * Uses a binary search to determine the lowest index at which a value should * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iterator function is provided it is executed for `value` - * and each element of `array` to compute their sort ranking. The iterator + * of the array. If an iteratee function is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The iteratee * function is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -3912,10 +4009,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3928,7 +4025,7 @@ * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; * - * // using an iterator function + * // using an iteratee function * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { * return this.data[word]; * }, dict); @@ -3938,9 +4035,9 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator); + function sortedIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee); } /** @@ -3953,10 +4050,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3964,9 +4061,9 @@ * _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); * // => 4 */ - function sortedLastIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator, true); + function sortedLastIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee, true); } /** @@ -4076,7 +4173,7 @@ index = length; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) { } + while (index-- && predicate(array[index], index, array)) {} return slice(array, index + 1); } @@ -4125,13 +4222,17 @@ length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) { } + while (++index < length && predicate(array[index], index, array)) {} return slice(array, 0, index); } /** * Creates an array of unique values, in order, of the provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -4148,30 +4249,34 @@ } /** - * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a - * faster search algorithm for sorted arrays. If an iterator function is - * provided it is executed for each value in the array to generate the criterion - * by which uniqueness is computed. The `iterator` is bound to `thisArg` and - * invoked with three arguments; (value, index, array). + * Creates a duplicate-value-free version of an array using `SameValueZero` + * for equality comparisons. Providing `true` for `isSorted` performs a faster + * search algorithm for sorted arrays. If an iteratee function is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @alias unique * @category Array * @param {Array} array The array to inspect. * @param {boolean} [isSorted=false] Specify the array is sorted. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new duplicate-value-free array. * @example * @@ -4182,7 +4287,7 @@ * _.uniq([1, 1, 2], true); * // => [1, 2] * - * // using an iterator function + * // using an iteratee function * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); * // => [1, 2.5] * @@ -4190,7 +4295,7 @@ * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, iterator, thisArg) { + function uniq(array, isSorted, iteratee, thisArg) { var length = array ? array.length : 0; if (!length) { return []; @@ -4198,21 +4303,21 @@ // juggle arguments var type = typeof isSorted; if (type != 'boolean' && isSorted != null) { - thisArg = iterator; - iterator = isSorted; + thisArg = iteratee; + iteratee = isSorted; isSorted = false; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === array) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { + iteratee = null; } } - if (iterator != null) { - iterator = getCallback(iterator, thisArg, 3); + if (iteratee != null) { + iteratee = getCallback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() == baseIndexOf) - ? sortedUniq(array, iterator) - : baseUniq(array, iterator); + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); } /** @@ -4245,8 +4350,12 @@ } /** - * Creates an array excluding all provided values using strict equality for - * comparisons, i.e. `===`. + * Creates an array excluding all provided values using `SameValueZero` for + * equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -4259,8 +4368,8 @@ * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); * // => [2, 3, 4] */ - function without() { - return baseDifference(arguments[0], slice(arguments, 1)); + function without(array) { + return baseDifference(array, slice(arguments, 1)); } /** @@ -4312,7 +4421,13 @@ * // => [['fred', 30, true], ['barney', 40, false]] */ function zip() { - return unzip(arguments); + var length = arguments.length, + array = Array(length); + + while (length--) { + array[length] = arguments[length]; + } + return unzip(array); } /** @@ -4504,9 +4619,13 @@ } /** - * Checks if `value` is present in `collection` using strict equality for - * comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the - * offset from the end of the collection. + * Checks if `value` is present in `collection` using `SameValueZero` for + * equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of the collection. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -4542,28 +4661,22 @@ } else { fromIndex = 0; } - if (typeof collection == 'string' || !isArray(collection) && isString(collection)) { - if (fromIndex >= length) { - return false; - } - return nativeContains - ? nativeContains.call(collection, target, fromIndex) - : collection.indexOf(target, fromIndex) > -1; - } - return getIndexOf(collection, target, fromIndex) > -1; + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) + : (getIndexOf(collection, target, fromIndex) > -1); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding value - * of each key is the number of times the key was returned by `iterator`. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4571,10 +4684,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4633,10 +4746,10 @@ * // => false */ function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arrayEvery : baseEvery; return func(collection, predicate); } @@ -4681,9 +4794,9 @@ * // => [{ 'name': 'barney', 'age': 36 }] */ function filter(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - var func = isArray(collection) ? arrayFilter : baseFilter; + + predicate = getCallback(predicate, thisArg, 3); return func(collection, predicate); } @@ -4791,12 +4904,12 @@ } /** - * Iterates over elements of `collection` executing `iterator` for each - * element. The `iterator` is bound to `thisArg` and invoked with three arguments; + * Iterates over elements of `collection` executing `iteratee` for each + * element. The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * - * Note: As with other "Collections" methods, objects with a `length` property + * **Note:** As with other "Collections" methods, objects with a `length` property * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` * may be used for object iteration. * @@ -4805,8 +4918,8 @@ * @alias each * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * @@ -4814,12 +4927,12 @@ * // => logs each value and returns the array * * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); - * // => logs each value-key pair and returns the object (property order is not guaranteed across environments) + * // => logs each value-key pair and returns the object (property order is not guaranteed) */ - function forEach(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iterator) - : baseEach(collection, baseCallback(iterator, thisArg, 3)); + function forEach(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEach(collection, iteratee) + : baseEach(collection, baseCallback(iteratee, thisArg, 3)); } /** @@ -4831,31 +4944,31 @@ * @alias eachRight * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); * // => logs each value from right to left and returns the array */ - function forEachRight(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEachRight(collection, iterator) - : baseEachRight(collection, baseCallback(iterator, thisArg, 3)); + function forEachRight(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEachRight(collection, iteratee) + : baseEachRight(collection, baseCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding + * each element of `collection` through `iteratee`. The corresponding * value of each key is an array of the elements responsible for generating - * the key. The `iterator` is bound to `thisArg` and invoked with three + * the key. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4863,10 +4976,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4890,15 +5003,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iterator`. The corresponding value + * each element of the collection through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4906,10 +5019,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4959,13 +5072,13 @@ /** * Creates an array of values by running each element in the collection through - * `iterator`. The `iterator` is bound to `thisArg` and invoked with three + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4974,10 +5087,10 @@ * @alias collect * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new mapped array. * @example * @@ -4985,7 +5098,7 @@ * // => [3, 6, 9] * * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); - * // => [3, 6, 9] (property order is not guaranteed across environments) + * // => [3, 6, 9] (property order is not guaranteed) * * var characters = [ * { 'name': 'barney', 'age': 36 }, @@ -4996,24 +5109,24 @@ * _.map(characters, 'name'); * // => ['barney', 'fred'] */ - function map(collection, iterator, thisArg) { - iterator = getCallback(iterator, thisArg, 3); + function map(collection, iteratee, thisArg) { + iteratee = getCallback(iteratee, thisArg, 3); var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, iterator); + return func(collection, iteratee); } /** * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iterator function is provided it + * or falsey `-Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -5021,10 +5134,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the maximum value. * @example * @@ -5046,20 +5159,20 @@ * _.max(characters, 'age'); * // => { 'name': 'fred', 'age': 40 }; */ - function max(collection, iterator, thisArg) { + function max(collection, iteratee, thisArg) { var computed = -Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, - isArr = noIterator && isArray(collection), + var noIteratee = iteratee == null, + isArr = noIteratee && isArray(collection), isStr = !isArr && isString(collection); - if (noIterator && !isStr) { + if (noIteratee && !isStr) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -5071,12 +5184,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIteratee && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current > computed || (current === -Infinity && current === result)) { computed = current; result = value; @@ -5088,15 +5201,15 @@ /** * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iterator function is provided it + * or falsey `Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -5104,10 +5217,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the minimum value. * @example * @@ -5129,20 +5242,20 @@ * _.min(characters, 'age'); * // => { 'name': 'barney', 'age': 36 }; */ - function min(collection, iterator, thisArg) { + function min(collection, iteratee, thisArg) { var computed = Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, - isArr = noIterator && isArray(collection), + var noIteratee = iteratee == null, + isArr = noIteratee && isArray(collection), isStr = !isArr && isString(collection); - if (noIterator && !isStr) { + if (noIteratee && !isStr) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -5154,12 +5267,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIteratee && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current < computed || (current === Infinity && current === result)) { computed = current; result = value; @@ -5242,10 +5355,10 @@ /** * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iterator`, where each successive + * each element in the collection through `iteratee`, where each successive * execution consumes the return value of the previous execution. If `accumulator` * is not provided the first element of the collection is used as the initial - * value. The `iterator` is bound to `thisArg`and invoked with four arguments; + * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * * @static @@ -5253,9 +5366,9 @@ * @alias foldl, inject * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5266,11 +5379,11 @@ * result[key] = n * 3; * return result; * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * // => { 'a': 3, 'b': 6, 'c': 9 } (property order is not guaranteed) */ - function reduce(collection, iterator, accumulator, thisArg) { + function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); } /** @@ -5282,9 +5395,9 @@ * @alias foldr * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5292,9 +5405,9 @@ * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iterator, accumulator, thisArg) { + function reduceRight(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); } /** @@ -5336,8 +5449,12 @@ * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] */ function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); - return filter(collection, negate(predicate)); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); } /** @@ -5471,27 +5588,27 @@ * // => false */ function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arraySome : baseSome; return func(collection, predicate); } /** * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iterator`. This method performs + * running each element in a collection through `iteratee`. This method performs * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * 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 `iterator` the collection + * If an array of property names is provided for `iteratee` the collection * is sorted by each property value. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -5499,10 +5616,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [iterator=identity] The function + * @param {Array|Function|Object|string} [iteratee=identity] The function * called per iteration. If property name(s) or an object is provided it * is used to create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example * @@ -5527,28 +5644,28 @@ * _.map(_.sortBy(characters, ['name', 'age']), _.values); * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortBy(collection, iterator, thisArg) { + function sortBy(collection, iteratee, thisArg) { var index = -1, length = collection ? collection.length : 0, - multi = iterator && isArray(iterator), + multi = iteratee && isArray(iteratee), result = []; if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { result.length = length; } if (!multi) { - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); } baseEach(collection, function(value, key, collection) { if (multi) { - var length = iterator.length, + var length = iteratee.length, criteria = Array(length); while (length--) { - criteria[length] = value[iterator[length]]; + criteria[length] = value == null ? undefined : value[iteratee[length]]; } } else { - criteria = iterator(value, key, collection); + criteria = iteratee(value, key, collection); } result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); @@ -5579,7 +5696,7 @@ if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { return (support.unindexedChars && isString(collection)) ? collection.split('') - : slice(collection); + : baseSlice(collection); } return values(collection); } @@ -5687,7 +5804,7 @@ * and prepends any additional `bind` arguments to those provided to the bound * function. * - * Note: Unlike native `Function#bind` this method does not set the `length` + * **Note:** Unlike native `Function#bind` this method does not set the `length` * property of bound functions. * * @static @@ -5709,12 +5826,12 @@ */ function bind(func, thisArg) { if (arguments.length < 3) { - return createWrapper([func, BIND_FLAG, null, thisArg]); + return createWrapper(func, BIND_FLAG, null, thisArg); } var args = slice(arguments, 2), - partialHolders = replaceHolders(args, bind.placeholder); + holders = replaceHolders(args, bind.placeholder); - return basePartial(func, BIND_FLAG | PARTIAL_FLAG, args, partialHolders, thisArg); + return basePartial(func, BIND_FLAG | PARTIAL_FLAG, args, holders, thisArg); } /** @@ -5723,7 +5840,7 @@ * of method names. If no method names are provided all enumerable function * properties, own and inherited, of `object` are bound. * - * Note: This method does not set the `length` property of bound functions. + * **Note:** This method does not set the `length` property of bound functions. * * @static * @memberOf _ @@ -5787,12 +5904,14 @@ * // => 'hiya fred!' */ function bindKey(object, key) { - var data = [key, BIND_FLAG | BIND_KEY_FLAG, null, object]; + var bitmask = BIND_FLAG | BIND_KEY_FLAG; if (arguments.length > 2) { - var args = slice(arguments, 2); - data.push(args, replaceHolders(args, bindKey.placeholder)); + var args = slice(arguments, 2), + holders = replaceHolders(args, bindKey.placeholder); } - return createWrapper(data); + return args + ? createWrapper(key, bitmask, null, object, args, holders) + : createWrapper(key, bitmask, null, object); } /** @@ -5856,7 +5975,7 @@ * remaining `func` arguments, and so on. The arity of `func` can be specified * if `func.length` is not sufficient. * - * Note: This method does not set the `length` property of curried functions. + * **Note:** This method does not set the `length` property of curried functions. * * @static * @memberOf _ @@ -5889,7 +6008,7 @@ * This method is like `_.curry` except that arguments are applied to `func` * in the manner of `_.partialRight` instead of `_.partial`. * - * Note: This method does not set the `length` property of curried functions. + * **Note:** This method does not set the `length` property of curried functions. * * @static * @memberOf _ @@ -5926,7 +6045,7 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * @@ -6247,7 +6366,7 @@ * prepended to those provided to the new function. This method is similar to * `_.bind` except it does **not** alter the `this` binding. * - * Note: This method does not set the `length` property of partially applied + * **Note:** This method does not set the `length` property of partially applied * functions. * * @static @@ -6265,16 +6384,16 @@ */ function partial(func) { var args = slice(arguments, 1), - partialHolders = replaceHolders(args, partial.placeholder); + holders = replaceHolders(args, partial.placeholder); - return basePartial(func, PARTIAL_FLAG, args, partialHolders); + return basePartial(func, PARTIAL_FLAG, args, holders); } /** * 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 + * **Note:** This method does not set the `length` property of partially applied * functions. * * @static @@ -6303,9 +6422,9 @@ */ function partialRight(func) { var args = slice(arguments, 1), - partialHolders = replaceHolders(args, partialRight.placeholder); + holders = replaceHolders(args, partialRight.placeholder); - return basePartial(func, PARTIAL_RIGHT_FLAG, args, partialHolders); + return basePartial(func, PARTIAL_RIGHT_FLAG, args, holders); } /** @@ -6316,7 +6435,7 @@ * Subsequent calls to the throttled function return the result of the last * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * @@ -6429,7 +6548,7 @@ * cloning is handled by the method instead. The `customizer` is bound to * `thisArg` and invoked with two argument; (value, index|key). * - * Note: This method is loosely based on the structured clone algorithm. Functions + * **Note:** This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and * objects created by constructors other than `Object` are cloned to plain `Object` objects. * See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) @@ -6492,7 +6611,7 @@ * is handled by the method instead. The `customizer` is bound to `thisArg` * and invoked with two argument; (value, index|key). * - * Note: This method is loosely based on the structured clone algorithm. Functions + * **Note:** This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and * objects created by constructors other than `Object` are cloned to plain `Object` objects. * See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) @@ -6574,7 +6693,7 @@ * object for all destination properties that resolve to `undefined`. Once a * property is set, additional defaults of the same property are ignored. * - * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) + * **Note:** See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. * * @static @@ -6592,7 +6711,7 @@ if (object == null) { return object; } - var args = slice(arguments); + var args = baseSlice(arguments); args.push(assignDefaults); return assign.apply(undefined, args); } @@ -6628,7 +6747,7 @@ * _.findKey(characters, function(chr) { * return chr.age < 40; * }); - * // => 'barney' (property order is not guaranteed across environments) + * // => 'barney' (property order is not guaranteed) * * // using "_.where" callback shorthand * _.findKey(characters, { 'age': 1 }); @@ -6691,7 +6810,7 @@ /** * Iterates over own and inherited enumerable properties of an object executing - * `iterator` for each property. The `iterator` is bound to `thisArg` and invoked + * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, key, object). Iterator functions may exit * iteration early by explicitly returning `false`. * @@ -6699,8 +6818,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6714,13 +6833,13 @@ * _.forIn(new Shape, function(value, key) { * console.log(key); * }); - * // => logs 'x', 'y', and 'z' (property order is not guaranteed across environments) + * // => logs 'x', 'y', and 'z' (property order is not guaranteed) */ - function forIn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forIn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseFor(object, iterator, keysIn); + return baseFor(object, iteratee, keysIn); } /** @@ -6731,8 +6850,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6748,14 +6867,14 @@ * }); * // => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z' */ - function forInRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keysIn); + function forInRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keysIn); } /** - * Iterates over own enumerable properties of an object executing `iterator` - * for each property. The `iterator` is bound to `thisArg` and invoked with + * Iterates over own enumerable properties of an object executing `iteratee` + * for each property. The `iteratee` is bound to `thisArg` and invoked with * three arguments; (value, key, object). Iterator functions may exit iteration * early by explicitly returning `false`. * @@ -6763,21 +6882,21 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); - * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) + * // => logs '0', '1', and 'length' (property order is not guaranteed) */ - function forOwn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forOwn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseForOwn(object, iterator); + return baseForOwn(object, iteratee); } /** @@ -6788,8 +6907,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6798,9 +6917,9 @@ * }); * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' */ - function forOwnRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keys); + function forOwnRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keys); } /** @@ -6812,14 +6931,14 @@ * @alias methods * @category Object * @param {Object} object The object to inspect. - * @returns {Array} Returns the new sorted array of property names. + * @returns {Array} Returns the new array of property names. * @example * * _.functions(_); * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] */ function functions(object) { - return baseFunctions(object, keysIn); + return baseFunctions(object, keysIn(object)); } /** @@ -6999,7 +7118,7 @@ */ function isElement(value) { return (value && typeof value == 'object' && value.nodeType === 1 && - (support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isNode(value))) || false; + (support.nodeClass ? toString.call(value).indexOf('Element') > -1 : isHostObject(value))) || false; } // fallback for environments without DOM support if (!support.dom) { @@ -7056,7 +7175,7 @@ * instead. The `customizer` is bound to `thisArg` and invoked with three * arguments; (value, other, key). * - * Note: This method supports comparing arrays, booleans, `Date` objects, + * **Note:** This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes * are **not** supported. Provide a customizer function to extend support * for comparing other values. @@ -7119,7 +7238,7 @@ /** * Checks if `value` is a finite primitive number. * - * Note: This method is based on ES6 `Number.isFinite`. See the + * **Note:** This method is based on ES6 `Number.isFinite`. See the * [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) * for more details. * @@ -7181,7 +7300,7 @@ * Checks if `value` is the language type of `Object`. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * - * Note: See the [ES5 spec](http://es5.github.io/#x8) for more details. + * **Note:** See the [ES5 spec](http://es5.github.io/#x8) for more details. * * @static * @memberOf _ @@ -7209,7 +7328,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which returns `true` + * **Note:** This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -7238,6 +7357,27 @@ return isNumber(value) && value != +value; } + /** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Object + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + */ + function isNative(value) { + if (isFunction(value)) { + return reNative.test(fnToString.call(value)); + } + if (value && typeof value == 'object') { + return !('constructor' in value) && isHostObject(value) + ? reNative.test(value) + : reHostCtor.test(toString.call(value)); + } + return false; + } + /** * Checks if `value` is `null`. * @@ -7261,7 +7401,7 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * Note: To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified * as numbers, use the `_.isFinite` method. * * @static @@ -7290,7 +7430,7 @@ * Checks if `value` is an object created by the `Object` constructor or has * a `[[Prototype]]` of `null`. * - * Note: This method assumes objects created by the `Object` constructor + * **Note:** This method assumes objects created by the `Object` constructor * have no inherited enumerable properties. * * @static @@ -7408,7 +7548,7 @@ * Shape.prototype.z = 0; * * _.keys(new Shape); - * // => ['x', 'y'] (property order is not guaranteed across environments) + * // => ['x', 'y'] (property order is not guaranteed) */ var keys = !nativeKeys ? shimKeys : function(object) { object = toObject(object); @@ -7442,7 +7582,7 @@ * Shape.prototype.z = 0; * * _.keysIn(new Shape); - * // => ['x', 'y', 'z'] (property order is not guaranteed across environments) + * // => ['x', 'y', 'z'] (property order is not guaranteed) */ function keysIn(object) { if (object == null) { @@ -7500,14 +7640,14 @@ /** * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iterator`. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * running each own enumerable property of `object` through `iteratee`. The + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, key, object). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -7515,10 +7655,10 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the new mapped object. * @example * @@ -7534,12 +7674,12 @@ * _.mapValues(characters, 'age'); * // => { 'fred': 40, 'pebbles': 1 } */ - function mapValues(object, iterator, thisArg) { + function mapValues(object, iteratee, thisArg) { var result = {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); baseForOwn(object, function(value, key, object) { - result[key] = iterator(value, key, object); + result[key] = iteratee(value, key, object); }); return result; } @@ -7628,11 +7768,15 @@ if (object == null) { return {}; } - if (typeof predicate == 'function') { - return basePick(object, negate(getCallback(predicate, thisArg, 3))); + var iterable = toObject(object); + if (typeof predicate != 'function') { + var props = arrayMap(baseFlatten(arguments, false, false, 1), String); + return pickByArray(iterable, baseDifference(keysIn(iterable), props)); } - var omitProps = baseFlatten(arguments, false, false, 1); - return basePick(toObject(object), baseDifference(keysIn(object), arrayMap(omitProps, String))); + predicate = getCallback(predicate, thisArg, 3); + return pickByCallback(iterable, function(value, key, object) { + return !predicate(value, key, object); + }); } /** @@ -7647,7 +7791,7 @@ * @example * * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) + * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed) */ function pairs(object) { var index = -1, @@ -7693,18 +7837,17 @@ if (object == null) { return {}; } - return basePick(toObject(object), - typeof predicate == 'function' - ? getCallback(predicate, thisArg, 3) - : baseFlatten(arguments, false, false, 1) - ); + var iterable = toObject(object); + return typeof predicate == 'function' + ? pickByCallback(iterable, getCallback(predicate, thisArg, 3)) + : pickByArray(iterable, baseFlatten(arguments, false, false, 1)); } /** * An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own - * enumerable properties through `iterator`, with each execution potentially - * mutating the `accumulator` object. The `iterator` is bound to `thisArg` + * enumerable properties through `iteratee`, with each execution potentially + * mutating the `accumulator` object. The `iteratee` is bound to `thisArg` * and invoked with four arguments; (accumulator, value, key, object). Iterator * functions may exit iteration early by explicitly returning `false`. * @@ -7712,9 +7855,9 @@ * @memberOf _ * @category Object * @param {Array|Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -7731,7 +7874,7 @@ * }); * // => { 'a': 3, 'b': 6, 'c': 9 } */ - function transform(object, iterator, accumulator, thisArg) { + function transform(object, iteratee, accumulator, thisArg) { var isArr = isArrayLike(object); if (accumulator == null) { @@ -7745,10 +7888,10 @@ accumulator = baseCreate(proto); } } - if (iterator) { - iterator = getCallback(iterator, thisArg, 4); + if (iteratee) { + iteratee = getCallback(iteratee, thisArg, 4); (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iterator(accumulator, value, index, object); + return iteratee(accumulator, value, index, object); }); } return accumulator; @@ -7772,7 +7915,7 @@ * Shape.prototype.z = 0; * * _.values(new Shape(2, 1)); - * // => [2, 1] (property order is not guaranteed across environments) + * // => [2, 1] (property order is not guaranteed) */ function values(object) { return baseValues(object, keys); @@ -7797,7 +7940,7 @@ * Shape.prototype.z = 0; * * _.valuesIn(new Shape(2, 1)); - * // => [2, 1, 0] (property order is not guaranteed across environments) + * // => [2, 1, 0] (property order is not guaranteed) */ function valuesIn(object) { return baseValues(object, keysIn); @@ -7888,7 +8031,7 @@ * Converts the characters "&", "<", ">", '"', and "'" in `string` to * their corresponding HTML entities. * - * Note: No other characters are escaped. To escape additional characters + * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * * When working with HTML you should always quote attribute values to reduce @@ -8155,7 +8298,7 @@ * properties may be accessed as free variables in the template. If a setting * object is provided it overrides `_.templateSettings` for the template. * - * Note: In the development build `_.template` utilizes sourceURLs for easier debugging. + * **Note:** In the development build `_.template` utilizes sourceURLs for easier debugging. * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * @@ -8517,7 +8660,7 @@ * `&`, `<`, `>`, `"`, and `'` in `string` to their * corresponding characters. * - * Note: No other HTML entities are unescaped. To unescape additional HTML + * **Note:** No other HTML entities are unescaped. To unescape additional HTML * entities use a third-party library like [_he_](http://mths.be/he). * * @static @@ -8575,6 +8718,7 @@ * * @static * @memberOf _ + * @alias iteratee * @category Utility * @param {*} [func=identity] The value to convert to a callback. * @param {*} [thisArg] The `this` binding of the created callback. @@ -8691,7 +8835,7 @@ var isStrict = isStrictComparable(value); flags[index] = isStrict; - vals[index] = isStrict ? value : baseClone(value, false); + vals[index] = isStrict ? value : baseClone(value); } return function(object) { index = length; @@ -8748,16 +8892,20 @@ */ function mixin(object, source, options) { var chain = true, - methodNames = source && baseFunctions(source, keys); + isObj = isObject(source), + noOpts = options == null, + props = noOpts && isObj && keys(source), + methodNames = props && baseFunctions(source, props); - if (!source || (!options && !methodNames.length)) { - if (options == null) { + if ((props && props.length && !methodNames.length) || (noOpts && !isObj)) { + if (noOpts) { options = source; } + methodNames = false; source = object; object = this; - methodNames = baseFunctions(source, keys); } + methodNames || (methodNames = baseFunctions(source, keys(source))); if (options === false) { chain = false; } else if (isObject(options) && 'chain' in options) { @@ -8765,7 +8913,7 @@ } var index = -1, isFunc = isFunction(object), - length = methodNames ? methodNames.length : 0; + length = methodNames.length; while (++index < length) { var methodName = methodNames[index], @@ -8849,7 +8997,7 @@ * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, * in which case a `radix` of `16` is used. * - * Note: This method avoids differences in native ES3 and ES5 `parseInt` + * **Note:** This method avoids differences in native ES3 and ES5 `parseInt` * implementations. See the [ES5 spec](http://es5.github.io/#E) * for more details. * @@ -9077,16 +9225,16 @@ } /** - * Executes the iterator function `n` times, returning an array of the results - * of each execution. The `iterator` is bound to `thisArg` and invoked with + * Executes the iteratee function `n` times, returning an array of the results + * of each execution. The `iteratee` is bound to `thisArg` and invoked with * one argument; (index). * * @static * @memberOf _ * @category Utility - * @param {number} n The number of times to execute `iterator`. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {number} n The number of times to execute `iteratee`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the array of results. * @example * @@ -9099,18 +9247,18 @@ * _.times(3, function(n) { this.cast(n); }, mage); * // => also calls `mage.castSpell(n)` three times */ - function times(n, iterator, thisArg) { + function times(n, iteratee, thisArg) { n = nativeIsFinite(n = +n) && n > -1 ? n : 0; - iterator = baseCallback(iterator, thisArg, 1); + iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { - result[index] = iterator(index); + result[index] = iteratee(index); } else { - iterator(index); + iteratee(index); } } return result; @@ -9241,6 +9389,7 @@ lodash.each = forEach; lodash.eachRight = forEachRight; lodash.extend = assign; + lodash.iteratee = callback; lodash.methods = functions; lodash.object = zipObject; lodash.select = filter; @@ -9285,6 +9434,7 @@ lodash.isFinite = isFinite; lodash.isFunction = isFunction; lodash.isNaN = isNaN; + lodash.isNative = isNative; lodash.isNull = isNull; lodash.isNumber = isNumber; lodash.isObject = isObject; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 359d9fb81..1f6ea7fcd 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -3,73 +3,74 @@ * Lo-Dash 3.0.0-pre (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")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 v(n){for(var t=-1,r=n.length;++ti(t,f)&&l.push(f);return l}function qt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>k)return Qt(n,t);for(var e=-1,u=Fr(n);++e=r||r>k)return nr(n,t);for(var e=Fr(n);r--&&false!==t(e[r],r,e););return n}function Kt(n,t){var r=true;return qt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Vt(n,t){var r=[];return qt(n,function(n,e,u){t(n,e,u)&&r.push(n) -}),r}function Yt(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Jt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e>>1,f=r(n[a]),l=e?f<=t:fo(c,p)&&((t||f)&&c.push(p),l.push(s))}return l}function hr(n,t){for(var r=-1,e=t(n),u=e.length,o=Te(u);++re)return t;var u=typeof r[2]; -if("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2),3=t||t>k)return Ae(n);if(n=Ur(n),Cu.unindexedChars&&we(n))for(var r=-1;++re?_u(u+e,0):e||0;else if(e)return e=$r(n,t),u&&n[e]===t?e:-1;return r(n,t,e)}function Nr(n){return Pr(n,1) -}function Pr(n,t,r){var e=-1,u=n?n.length:0;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t,r=Te(u);++er?_u(e+r,0):r||0:0,typeof n=="string"||!Nu(n)&&we(n)?ro&&(o=a);else t=i&&a?u:Ar(t,r,3),qt(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===o)&&(e=r,o=n)});return o}function Qr(n,t){return Gr(n,Ue(t))}function ne(n,t,r,e){return(Nu(n)?Rt:lr)(n,Ar(t,e,4),r,3>arguments.length,qt)}function te(n,t,r,e){return(Nu(n)?kt:lr)(n,Ar(t,e,4),r,3>arguments.length,Zt)}function re(n){n=Fr(n); -for(var t=-1,r=n.length,e=Te(r);++targuments.length)return jr([n,w,null,t]);var r=Pr(arguments,2),e=Sr(r,oe.placeholder);return ir(n,w|E,r,e,t)}function ie(n,t){var r=[t,w|j,null,n];if(2=r||r>t?(a&&ru(a),r=p,a=s=p=_,r&&(h=Zu(),f=n.apply(c,i),s||a||(i=c=null))):s=lu(e,r)}function u(){s&&ru(s),a=s=p=_,(v||g!==t)&&(h=Zu(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=Zu(),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=lu(u,o))}return d&&s?s=ru(s):s||t===g||(s=lu(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(!de(n))throw new ze(S);if(t=0>t?0:t,true===r)var y=true,v=false;else me(r)&&(y=r.leading,g="maxWait"in r&&_u(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&ru(s),a&&ru(a),a=s=p=_},o}function ce(n){if(!de(n))throw new ze(S);return function(){return!n.apply(this,arguments)}}function se(n){var t=Pr(arguments,1),r=Sr(t,se.placeholder); -return ir(n,E,t,r)}function pe(n){var t=Pr(arguments,1),r=Sr(t,pe.placeholder);return ir(n,I,t,r)}function he(n){return tr(n,je)}function ge(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ge.call(n)==et||false}function ve(n){return n&&typeof n=="object"&&1===n.nodeType&&(Cu.nodeClass?-1t||null==n||!du(t))return r;n=Me(n);do t%2&&(r+=n),t=eu(t/2),n+=n; -while(t);return r}function Ee(n,t){return(n=null==n?"":Me(n))?null==t?n.slice(v(n),y(n)+1):(t=Me(t),n.slice(o(n,t),i(n,t)+1)):n}function Ie(n){try{return n()}catch(t){return ye(t)?t:We(t)}}function Ce(n,t){return Pt(n,t)}function Se(n){return n}function Re(n){var t=Bu(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Ir(u))return function(n){return null!=n&&u===n[e]&&ou.call(n,e)}}for(var o=r,i=Te(r),a=Te(r);o--;){var u=n[t[o]],f=Ir(u);i[o]=f,a[o]=f?u:$t(u,false)}return function(n){if(o=r,null==n)return!o; -for(;o--;)if(i[o]?a[o]!==n[t[o]]:!ou.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!ou.call(n,t[o]):!rr(a[o],n[t[o]],null,true))return false;return true}}function ke(n,t,r){var e=true,u=t&&tr(t,Bu);t&&(r||u.length)||(null==r&&(r=t),t=n,n=this,u=tr(t,Bu)),false===r?e=false:me(r)&&"chain"in r&&(e=r.chain),r=-1;for(var o=de(n),i=u?u.length:0;++r--n?t.apply(this,arguments):void 0}},g.assign=Wu,g.at=function(t){var r=t?t.length:0;return typeof r=="number"&&-1t?0:t)},g.dropRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),Pr(n,0,0>t?0:t)},g.dropRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Ar(t,r,3);e--&&t(n[e],e,n););return Pr(n,0,e+1)},g.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Ar(t,r,3);++e(p?e(p,f):i(s,f))){for(t=u;--t;){var h=o[t];if(0>(h?e(h,f):i(n[t],f)))continue n}p&&p.push(f),s.push(f)}return s},g.invert=function(n,t){for(var r=-1,e=Bu(n),u=e.length,o={};++rt?0:t)},g.takeRight=function(n,t,r){var e=n?n.length:0; -return t=e-((null==t||r?1:t)||0),Pr(n,0>t?0:t)},g.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Ar(t,r,3);e--&&t(n[e],e,n););return Pr(n,e+1)},g.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Ar(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},g.escape=function(n){return n=null==n?"":Me(n),$.lastIndex=0,$.test(n)?n.replace($,s):n -},g.escapeRegExp=xe,g.every=Kr,g.find=Yr,g.findIndex=Tr,g.findKey=function(n,t,r){return t=Ar(t,r,3),Yt(n,t,Qt,true)},g.findLast=function(n,t,r){return t=Ar(t,r,3),Yt(n,t,Zt)},g.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Ar(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},g.findLastKey=function(n,t,r){return t=Ar(t,r,3),Yt(n,t,nr,true)},g.findWhere=function(n,t){return Yr(n,Re(t))},g.first=Lr,g.has=function(n,t){return n?ou.call(n,t):false},g.identity=Se,g.indexOf=Wr,g.isArguments=ge,g.isArray=Nu,g.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Ge.call(n)==ot||false -},g.isDate=function(n){return n&&typeof n=="object"&&Ge.call(n)==it||false},g.isElement=ve,g.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?_u(u+r,0):bu(r||0,u-1))+1;else if(r)return u=Br(n,t)-1,e&&n[u]===t?u:-1;for(;u--;)if(n[u]===t)return u;return-1},g.max=Hr,g.min=function(n,t,r){var e=1/0,o=e,i=typeof t;"number"!=i&&"string"!=i||!r||r[t]!==n||(t=null);var i=null==t,a=!(i&&Nu(n))&&we(n);if(i&&!a)for(r=-1,n=Fr(n),i=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},g.template=function(n,t,r){var e=g.templateSettings;t=Wu({},r||t,e,Wt),n=Me(null==n?"":n),r=Wu({},t.imports,e.imports,Wt); -var u,o,i=Bu(r),a=Ae(r),f=0;r=t.interpolate||J;var l="__p+='";if(r=De((t.escape||J).source+"|"+r.source+"|"+(r===M?z:J).source+"|"+(t.evaluate||J).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(H,p),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(L,""):l).replace(W,"$1").replace(N,"$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=Ie(function(){return Ne(i,"return "+l).apply(_,a) -}),t.source=l,ye(t))throw t;return t},g.trim=Ee,g.trimLeft=function(n,t){return(n=null==n?"":Me(n))?null==t?n.slice(v(n)):(t=Me(t),n.slice(o(n,t))):n},g.trimRight=function(n,t){return(n=null==n?"":Me(n))?null==t?n.slice(0,y(n)+1):(t=Me(t),n.slice(0,i(n,t)+1)):n},g.trunc=function(n,t){var r=30,e="...";if(me(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Me(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Me(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e; -if(r=n.slice(0,o),null==u)return r+e;if(be(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=De(u.source,(q.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index;r=r.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Qt(g,function(n,t){var r="sample"!=t;g.prototype[t]||(g.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new Y(o,u):o})}),g.VERSION=b,g.prototype.chain=function(){return this.__chain__=true,this},g.prototype.toJSON=qr,g.prototype.toString=function(){return Me(this.__wrapped__) -},g.prototype.value=qr,g.prototype.valueOf=qr,Q(["join","pop","shift"],function(n){var t=qe[n];g.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new Y(r,n):r}}),Q(["push","reverse","sort","unshift"],function(n){var t=qe[n];g.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Q(["concat","splice"],function(n){var t=qe[n];g.prototype[n]=function(){return new Y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Cu.spliceObjects||Q(["pop","shift","splice"],function(n){var t=qe[n],r="splice"==n; -g.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new Y(u,n):u}}),g}var _,b="3.0.0-pre",w=1,j=2,A=4,x=8,O=16,E=32,I=64,C="__lodash_"+b.replace(/[-.]/g,"_")+"__",S="Expected a function",R=Math.pow(2,32)-1,k=Math.pow(2,53)-1,F="__lodash_placeholder__",U=0,T=/^[A-Z]+$/,L=/\b__p\+='';/g,W=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,P=/&(?:amp|lt|gt|quot|#39|#96);/g,$=/[&<>"'`]/g,B=/<%-([\s\S]+?)%>/g,D=/<%([\s\S]+?)%>/g,M=/<%=([\s\S]+?)%>/g,z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,q=/\w*$/,Z=/^\s*function[ \n\r\t]+\w/,K=/^0[xX]/,V=/^\[object .+?Constructor\]$/,Y=/[\xC0-\xFF]/g,J=/($^)/,X=/[.*+?^${}()|[\]\/\\]/g,G=/\bthis\b/,H=/['\n\r\u2028\u2029\\]/g,Q=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,nt=" \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",tt="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 window WinRTError".split(" "),rt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),et="[object Arguments]",ut="[object Array]",ot="[object Boolean]",it="[object Date]",at="[object Error]",ft="[object Function]",lt="[object Number]",ct="[object Object]",st="[object RegExp]",pt="[object String]",ht="[object ArrayBuffer]",gt="[object Float32Array]",vt="[object Float64Array]",yt="[object Int8Array]",dt="[object Int16Array]",mt="[object Int32Array]",_t="[object Uint8Array]",bt="[object Uint8ClampedArray]",wt="[object Uint16Array]",jt="[object Uint32Array]",At={}; -At[et]=At[ut]=At[gt]=At[vt]=At[yt]=At[dt]=At[mt]=At[_t]=At[bt]=At[wt]=At[jt]=true,At[ht]=At[ot]=At[it]=At[at]=At[ft]=At["[object Map]"]=At[lt]=At[ct]=At[st]=At["[object Set]"]=At[pt]=At["[object WeakMap]"]=false;var xt={};xt[et]=xt[ut]=xt[ht]=xt[ot]=xt[it]=xt[gt]=xt[vt]=xt[yt]=xt[dt]=xt[mt]=xt[lt]=xt[ct]=xt[st]=xt[pt]=xt[_t]=xt[bt]=xt[wt]=xt[jt]=true,xt[at]=xt[ft]=xt["[object Map]"]=xt["[object Set]"]=xt["[object WeakMap]"]=false;var Ot={leading:false,maxWait:0,trailing:false},Et={configurable:false,enumerable:false,value:null,writable:false},It={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ct={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},St={"\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","\xd7":" ","\xf7":" "},Rt={"function":true,object:true},kt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ft=Rt[typeof window]&&window||this,Ut=Rt[typeof exports]&&exports&&!exports.nodeType&&exports,Rt=Rt[typeof module]&&module&&!module.nodeType&&module,Tt=Ut&&Rt&&typeof global=="object"&&global; -!Tt||Tt.global!==Tt&&Tt.window!==Tt&&Tt.self!==Tt||(Ft=Tt);var Tt=Rt&&Rt.exports===Ut&&Ut,Lt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Ft._=Lt, define(function(){return Lt})):Ut&&Rt?Tt?(Rt.exports=Lt)._=Lt:Ut._=Lt:Ft._=Lt}).call(this); \ No newline at end of file +;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")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 v(n){for(var t=-1,r=n.length;++ti(t,f)&&l.push(f);return l}function Zt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>U)return nr(n,t); +for(var e=-1,u=Pr(n);++e=r||r>U)return tr(n,t);for(var e=Pr(n);r--&&false!==t(e[r],r,e););return n}function Vt(n,t){var r=true;return Zt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Yt(n,t){var r=[];return Zt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Jt(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Xt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e>>1,f=r(n[a]),l=e?f<=t:fo(c,p)&&((t||f)&&c.push(p),l.push(s))}return l}function gr(n,t){for(var r=-1,e=t(n),u=e.length,o=Me(u);++rt)return r;var e=typeof arguments[2];if("number"!=e&&"string"!=e||!arguments[3]||arguments[3][arguments[2]]!==arguments[1]||(t=2),3=t||t>U)return Se(n);if(n=$r(n),Nu.unindexedChars&&Ie(n))for(var r=-1;++re?Iu(u+e,0):e||0;else if(e)return e=Zr(n,t),u&&n[e]===t?e:-1; +return r(n,t,e)}function zr(n){return qr(n,1)}function qr(n,t,r){var u=-1,o=n?n.length:0;if(t=null==t?0:+t||0,0>t&&(t=-t>o?0:o+t),r=typeof r=="undefined"||r>o?o:+r||0,0>r&&(r+=o),r&&r==o&&!t)return e(n);for(o=t>r?0:r-t,r=Me(o);++ur?Iu(e+r,0):r||0:0,typeof n=="string"||!Vu(n)&&Ie(n)?ru&&(u=a);else t=i&&a?o:Er(t,r,3),Zt(n,function(n,r,o){r=t(n,r,o),(r>e||-1/0===r&&r===u)&&(e=r,u=n)});return u}function oe(n,t){return ee(n,De(t))}function ie(n,t,r,e){return(Vu(n)?Ft:lr)(n,Er(t,e,4),r,3>arguments.length,Zt)}function ae(n,t,r,e){return(Vu(n)?Ut:lr)(n,Er(t,e,4),r,3>arguments.length,Kt) +}function fe(n){n=Pr(n);for(var t=-1,r=n.length,e=Me(r);++targuments.length)return Or(n,w,null,t);var r=qr(arguments,2),e=Lr(r,se.placeholder);return ar(n,w|E,r,e,t)}function pe(n,t){var r=w|j;if(2=r||r>t?(a&&su(a),r=p,a=s=p=_,r&&(h=to(),f=n.apply(c,i),s||a||(i=c=null))):s=du(e,r)}function u(){s&&su(s),a=s=p=_,(v||g!==t)&&(h=to(),f=n.apply(c,i),s||a||(i=c=null))}function o(){if(i=arguments,l=to(),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=su(a)),h=l,f=n.apply(c,i)):a||(a=du(u,o))}return d&&s?s=su(s):s||t===g||(s=du(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(!je(n))throw new Ge(R);if(t=0>t?0:t,true===r)var y=true,v=false;else Ae(r)&&(y=r.leading,g="maxWait"in r&&Iu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){s&&su(s),a&&su(a),a=s=p=_},o}function ye(n){var t=qr(arguments,1),r=Lr(t,ye.placeholder);return ar(n,E,t,r)}function de(n){var t=qr(arguments,1),r=Lr(t,de.placeholder); +return ar(n,I,t,r)}function me(n){return rr(n,Ce(n))}function _e(n){return n&&typeof n=="object"&&typeof n.length=="number"&&iu.call(n)==ot||false}function be(n){return n&&typeof n=="object"&&1===n.nodeType&&(Nu.nodeClass?-1t||null==n||!Ou(t))return r;n=Xe(n);do t%2&&(r+=n),t=pu(t/2),n+=n; +while(t);return r}function Fe(n,t){return(n=null==n?"":Xe(n))?null==t?n.slice(v(n),y(n)+1):(t=Xe(t),n.slice(i(n,t),a(n,t)+1)):n}function Ue(n){try{return n()}catch(t){return we(t)?t:qe(t)}}function Te(n,t){return Bt(n,t)}function Le(n){return function(){return n}}function We(n){return n}function Ne(n){var t=Xu(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(Fr(u))return function(n){return null!=n&&u===n[e]&&uu.call(n,e)}}for(var o=r,i=Me(r),a=Me(r);o--;){var u=n[t[o]],f=Fr(u);i[o]=f,a[o]=f?u:Dt(u)}return function(n){if(o=r,null==n)return!o; +for(;o--;)if(i[o]?a[o]!==n[t[o]]:!uu.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!uu.call(n,t[o]):!er(a[o],n[t[o]],null,true))return false;return true}}function Pe(n,t,r){var e=true,u=Ae(t),o=null==r,i=o&&u&&Xu(t),a=i&&rr(t,i);(i&&i.length&&!a.length||o&&!u)&&(o&&(r=t),a=false,t=n,n=this),a||(a=rr(t,Xu(t))),false===r?e=false:Ae(r)&&"chain"in r&&(e=r.chain),r=-1,u=je(n);for(o=a.length;++rC)return r +}else n=0;return cr(r,e)}}(),Du=mr(function(n,t,r){uu.call(n,r)?++n[r]:n[r]=1}),Mu=mr(function(n,t,r){uu.call(n,r)?n[r].push(t):n[r]=[t]}),zu=mr(function(n,t,r){n[r]=t}),qu=mr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Zu=ye(ce,2),Ku=_r($t);Nu.argsClass||(_e=function(n){var t=n&&typeof n=="object"?n.length:_;return typeof t=="number"&&-1--n?t.apply(this,arguments):void 0}},g.assign=Ku,g.at=function(t){var r=t?t.length:0;return typeof r=="number"&&-1t?0:t)},g.dropRight=function(n,t,r){var e=n?n.length:0; +return t=e-((null==t||r?1:t)||0),qr(n,0,0>t?0:t)},g.dropRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Er(t,r,3);e--&&t(n[e],e,n););return qr(n,0,e+1)},g.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Er(t,r,3);++e(p?u(p,f):i(s,f))){for(t=e;--t;){var h=o[t];if(0>(h?u(h,f):i(n[t],f)))continue n}p&&p.push(f),s.push(f)}return s},g.invert=function(n,t){for(var r=-1,e=Xu(n),u=e.length,o={};++rt?0:t)},g.takeRight=function(n,t,r){var e=n?n.length:0; +return t=e-((null==t||r?1:t)||0),qr(n,0>t?0:t)},g.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=Er(t,r,3);e--&&t(n[e],e,n););return qr(n,e+1)},g.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=Er(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},g.escape=function(n){return n=null==n?"":Xe(n),D.lastIndex=0,D.test(n)?n.replace(D,p):n +},g.escapeRegExp=ke,g.every=Hr,g.find=ne,g.findIndex=Br,g.findKey=function(n,t,r){return t=Er(t,r,3),Jt(n,t,nr,true)},g.findLast=function(n,t,r){return t=Er(t,r,3),Jt(n,t,Kt)},g.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=Er(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},g.findLastKey=function(n,t,r){return t=Er(t,r,3),Jt(n,t,tr,true)},g.findWhere=function(n,t){return ne(n,Ne(t))},g.first=Dr,g.has=function(n,t){return n?uu.call(n,t):false},g.identity=We,g.indexOf=Mr,g.isArguments=_e,g.isArray=Vu,g.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&iu.call(n)==at||false +},g.isDate=function(n){return n&&typeof n=="object"&&iu.call(n)==ft||false},g.isElement=be,g.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?Iu(u+r,0):Cu(r||0,u-1))+1;else if(r)return u=Kr(n,t)-1,e&&n[u]===t?u:-1;for(r=t===t;u--;)if(e=n[u],r?e===t:e!==e)return u;return-1},g.max=ue,g.min=function(n,t,r){var e=1/0,u=e,i=typeof t;"number"!=i&&"string"!=i||!r||r[t]!==n||(t=null);var i=null==t,a=!(i&&Vu(n))&&Ie(n);if(i&&!a)for(r=-1,n=Pr(n),i=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},g.template=function(n,t,r){var e=g.templateSettings;t=Ku({},r||t,e,Pt),n=Xe(null==n?"":n),r=Ku({},t.imports,e.imports,Pt); +var u,o,i=Xu(r),a=Se(r),f=0;r=t.interpolate||G;var l="__p+='";if(r=Je((t.escape||G).source+"|"+r.source+"|"+(r===q?Z:G).source+"|"+(t.evaluate||G).source+"|$","g"),n.replace(r,function(t,r,e,i,a,c){return e||(e=i),l+=n.slice(f,c).replace(nt,h),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(N,""):l).replace(P,"$1").replace($,"$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=Ue(function(){return Ze(i,"return "+l).apply(_,a) +}),t.source=l,we(t))throw t;return t},g.trim=Fe,g.trimLeft=function(n,t){return(n=null==n?"":Xe(n))?null==t?n.slice(v(n)):(t=Xe(t),n.slice(i(n,t))):n},g.trimRight=function(n,t){return(n=null==n?"":Xe(n))?null==t?n.slice(0,y(n)+1):(t=Xe(t),n.slice(0,a(n,t)+1)):n},g.trunc=function(n,t){var r=30,e="...";if(Ae(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Xe(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Xe(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e; +if(r=n.slice(0,o),null==u)return r+e;if(Ee(u)){if(n.slice(o).search(u)){var i,a,f=n.slice(0,o);for(u.global||(u=Je(u.source,(K.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(f);)a=i.index;r=r.slice(0,null==a?o:a)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n)},nr(g,function(n,t){var r="sample"!=t;g.prototype[t]||(g.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new X(o,u):o})}),g.VERSION=b,g.prototype.chain=function(){return this.__chain__=true,this},g.prototype.toJSON=Xr,g.prototype.toString=function(){return Xe(this.__wrapped__) +},g.prototype.value=Xr,g.prototype.valueOf=Xr,tt(["join","pop","shift"],function(n){var t=He[n];g.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new X(r,n):r}}),tt(["push","reverse","sort","unshift"],function(n){var t=He[n];g.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),tt(["concat","splice"],function(n){var t=He[n];g.prototype[n]=function(){return new X(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Nu.spliceObjects||tt(["pop","shift","splice"],function(n){var t=He[n],r="splice"==n; +g.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new X(u,n):u}}),g}var _,b="3.0.0-pre",w=1,j=2,A=4,x=8,O=16,E=32,I=64,C=150,S=16,k="__lodash_"+b.replace(/[-.]/g,"_")+"__",R="Expected a function",F=Math.pow(2,32)-1,U=Math.pow(2,53)-1,T="__lodash_placeholder__",L=0,W=/^[A-Z]+$/,N=/\b__p\+='';/g,P=/\b(__p\+=)''\+/g,$=/(__e\(.*?\)|\b__t\))\+'';/g,B=/&(?:amp|lt|gt|quot|#39|#96);/g,D=/[&<>"'`]/g,M=/<%-([\s\S]+?)%>/g,z=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,Z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,K=/\w*$/,V=/^\s*function[ \n\r\t]+\w/,Y=/^0[xX]/,J=/^\[object .+?Constructor\]$/,X=/[\xC0-\xFF]/g,G=/($^)/,H=/[.*+?^${}()|[\]\/\\]/g,Q=/\bthis\b/,nt=/['\n\r\u2028\u2029\\]/g,tt=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,rt=" \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",et="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(" "),ut="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),ot="[object Arguments]",it="[object Array]",at="[object Boolean]",ft="[object Date]",lt="[object Error]",ct="[object Function]",st="[object Number]",pt="[object Object]",ht="[object RegExp]",gt="[object String]",vt="[object ArrayBuffer]",yt="[object Float32Array]",dt="[object Float64Array]",mt="[object Int8Array]",_t="[object Int16Array]",bt="[object Int32Array]",wt="[object Uint8Array]",jt="[object Uint8ClampedArray]",At="[object Uint16Array]",xt="[object Uint32Array]",Ot={}; +Ot[ot]=Ot[it]=Ot[yt]=Ot[dt]=Ot[mt]=Ot[_t]=Ot[bt]=Ot[wt]=Ot[jt]=Ot[At]=Ot[xt]=true,Ot[vt]=Ot[at]=Ot[ft]=Ot[lt]=Ot[ct]=Ot["[object Map]"]=Ot[st]=Ot[pt]=Ot[ht]=Ot["[object Set]"]=Ot[gt]=Ot["[object WeakMap]"]=false;var Et={};Et[ot]=Et[it]=Et[vt]=Et[at]=Et[ft]=Et[yt]=Et[dt]=Et[mt]=Et[_t]=Et[bt]=Et[st]=Et[pt]=Et[ht]=Et[gt]=Et[wt]=Et[jt]=Et[At]=Et[xt]=true,Et[lt]=Et[ct]=Et["[object Map]"]=Et["[object Set]"]=Et["[object WeakMap]"]=false;var It={leading:false,maxWait:0,trailing:false},Ct={configurable:false,enumerable:false,value:null,writable:false},St={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},kt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Rt={"\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","\xd7":" ","\xf7":" "},Ft={"function":true,object:true},Ut={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tt=Ft[typeof window]&&window||this,Lt=Ft[typeof exports]&&exports&&!exports.nodeType&&exports,Ft=Ft[typeof module]&&module&&!module.nodeType&&module,Wt=Lt&&Ft&&typeof global=="object"&&global; +!Wt||Wt.global!==Wt&&Wt.window!==Wt&&Wt.self!==Wt||(Tt=Wt);var Wt=Ft&&Ft.exports===Lt&&Lt,Nt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Tt._=Nt, define(function(){return Nt})):Lt&&Ft?Wt?(Ft.exports=Nt)._=Nt:Lt._=Nt:Tt._=Nt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index c4f291d03..97228c370 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -24,6 +24,10 @@ PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64; + /** Used to detect when a function becomes hot */ + var HOT_COUNT = 150, + HOT_SPAN = 16; + /** Used as the property name for wrapper metadata */ var EXPANDO = '__lodash_' + VERSION.replace(/[-.]/g, '_') + '__'; @@ -122,7 +126,8 @@ 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number', 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'document', 'isFinite', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', - 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'window', 'WinRTError' + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', + 'window', 'WinRTError' ]; /** Used to make template sourceURLs easier to identify */ @@ -202,7 +207,7 @@ /** * Used to convert characters to HTML entities. * - * Note: Though the ">" character is escaped for symmetry, characters like + * **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' article](http://mathiasbynens.be/notes/ambiguous-ampersands) @@ -345,16 +350,37 @@ */ function baseIndexOf(array, value, fromIndex) { var index = (fromIndex || 0) - 1, - length = array ? array.length : 0; + length = array ? array.length : 0, + isReflexive = value === value; while (++index < length) { - if (array[index] === value) { + var other = array[index]; + if ((isReflexive ? other === value : other !== other)) { return index; } } return -1; } + /** + * The base implementation of `_.slice` without support for `start` and `end` + * arguments. + * + * @private + * @param {Array} array The array to slice. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array) { + var index = -1, + length = array ? array.length : 0, + result = Array(length); + + while (++index < length) { + result[index] = array[index]; + } + return result; + } + /** * An implementation of `_.contains` for cache objects that mimics the return * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. @@ -393,7 +419,7 @@ var index = -1, length = string.length; - while (++index < length && chars.indexOf(string.charAt(index)) > -1) { } + while (++index < length && chars.indexOf(string.charAt(index)) > -1) {} return index; } @@ -409,7 +435,7 @@ function charsRightIndex(string, chars) { var index = string.length; - while (index-- && chars.indexOf(string.charAt(index)) > -1) { } + while (index-- && chars.indexOf(string.charAt(index)) > -1) {} return index; } @@ -538,7 +564,7 @@ var index = -1, length = string.length; - while (++index < length && isWhitespace(string.charCodeAt(index))) { } + while (++index < length && isWhitespace(string.charCodeAt(index))) {} return index; } @@ -553,7 +579,7 @@ function trimmedRightIndex(string) { var index = string.length; - while (index-- && isWhitespace(string.charCodeAt(index))) { } + while (index-- && isWhitespace(string.charCodeAt(index))) {} return index; } @@ -618,8 +644,7 @@ /** Used for native method references */ var arrayProto = Array.prototype, - objectProto = Object.prototype, - stringProto = String.prototype; + objectProto = Object.prototype; /** Used to detect DOM support */ var document = (document = context.window) && document.document; @@ -627,6 +652,9 @@ /** Used to resolve the decompiled source of functions */ var fnToString = Function.prototype.toString; + /** Used to check objects for own properties */ + var hasOwnProperty = objectProto.hasOwnProperty; + /** Used to restore the original `_` reference in `_.noConflict` */ var oldDash = context._; @@ -646,13 +674,13 @@ clearTimeout = context.clearTimeout, floor = Math.floor, getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, - hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, propertyIsEnumerable = objectProto.propertyIsEnumerable, Set = isNative(Set = context.Set) && Set, setTimeout = context.setTimeout, splice = arrayProto.splice, - Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array; + Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, + WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; /** Used to clone array buffers */ var Float64Array = (function() { @@ -662,7 +690,7 @@ try { var func = isNative(func = context.Float64Array) && func, result = new func(new ArrayBuffer(10), 0, 1) && func; - } catch(e) { } + } catch(e) {} return result; }()); @@ -673,13 +701,12 @@ var o = {}, func = isNative(func = Object.defineProperty) && func, result = func(o, o, o) && func; - } catch(e) { } + } catch(e) {} return result; }()); /* Native method references for those with the same name as other `lodash` methods */ - var nativeContains = isNative(nativeContains = stringProto.contains) && nativeContains, - nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, + var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, nativeIsFinite = context.isFinite, nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, @@ -693,6 +720,9 @@ /** Used as the size, in bytes, of each Float64Array element */ var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; + /** Used to store function metadata */ + var metaMap = WeakMap && new WeakMap; + /*--------------------------------------------------------------------------*/ /** @@ -724,17 +754,17 @@ * * The non-chainable wrapper functions are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `contains`, - * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, isDate`, + * `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`, - * `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`, and `value` + * `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`, and `value` * * The wrapper function `sample` will return a wrapped value when `n` is * provided, otherwise it will return an unwrapped value. @@ -799,8 +829,6 @@ (function(x) { - for (var argsKey in arguments) { } - /** * Detect if functions can be decompiled by `Function#toString` * (all but Firefox OS certified apps, older Opera mobile browsers, and @@ -831,6 +859,18 @@ support.dom = false; } + /** + * Detect if the host objects are detectable (IE < 9). + * + * @memberOf _.support + * @type boolean + */ + try { + support.hostObject = !({ 'toString': 0 } + ''); + } catch(e) { + support.hostObject = false; + } + /** * Detect if `arguments` object indexes are non-enumerable. * @@ -844,7 +884,7 @@ * @type boolean */ try { - support.nonEnumArgs = !(hasOwnProperty.call(arguments, 1) && propertyIsEnumerable.call(arguments, 1)); + support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1); } catch(e) { support.nonEnumArgs = true; } @@ -919,15 +959,15 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEach(array, iterator) { + function arrayEach(array, iteratee) { var index = -1, length = array.length; while (++index < length) { - if (iterator(array[index], index, array) === false) { + if (iteratee(array[index], index, array) === false) { break; } } @@ -940,14 +980,14 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEachRight(array, iterator) { + function arrayEachRight(array, iteratee) { var length = array.length; while (length--) { - if (iterator(array[length], length, array) === false) { + if (iteratee(array[length], length, array) === false) { break; } } @@ -982,16 +1022,16 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function arrayMap(array, iterator) { + function arrayMap(array, iteratee) { var index = -1, length = array.length, result = Array(length); while (++index < length) { - result[index] = iterator(array[index], index, array); + result[index] = iteratee(array[index], index, array); } return result; } @@ -1008,12 +1048,13 @@ function arrayFilter(array, predicate) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { - result.push(value); + result[++resIndex] = value; } } return result; @@ -1025,13 +1066,13 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iterator, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1, length = array.length; @@ -1039,7 +1080,7 @@ accumulator = array[++index]; } while (++index < length) { - accumulator = iterator(accumulator, array[index], index, array); + accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } @@ -1050,20 +1091,20 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iterator, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; if (initFromArray && length) { accumulator = array[--length]; } while (length--) { - accumulator = iterator(accumulator, array[length], length, array); + accumulator = iteratee(accumulator, array[length], length, array); } return accumulator; } @@ -1107,7 +1148,7 @@ /** * Used by `_.template` to customize its `_.assign` use. * - * Note: This method is like `assignDefaults` except that it ignores + * **Note:** This method is like `assignDefaults` except that it ignores * inherited property values when checking if a property is `undefined`. * * @private @@ -1162,7 +1203,7 @@ while (++index < length) { var key = methodNames[index]; - object[key] = createWrapper([object[key], BIND_FLAG, null, object]); + object[key] = createWrapper(object[key], BIND_FLAG, null, object); } return object; } @@ -1184,7 +1225,7 @@ if (typeof thisArg == 'undefined') { return func; } - var data = func[EXPANDO]; + var data = getData(func); if (typeof data == 'undefined') { if (support.funcNames) { data = !func.name; @@ -1198,7 +1239,7 @@ if (!data) { // checks if `func` references the `this` keyword and stores the result data = reThis.test(source) || isNative(func); - setData(func, data); + baseSetData(func, data); } } } @@ -1248,75 +1289,15 @@ if (typeof result != 'undefined') { return result; } - var isArr = isArray(value), - isShallow = !isDeep; - + var isArr = isArray(value); + result = value; if (isArr) { - result = isShallow ? slice(value) : value.constructor(value.length); - - // add array properties assigned by `RegExp#exec` - if (typeof value[0] == 'string' && hasOwnProperty.call(value, 'index')) { - result.index = value.index; - result.input = value.input; - } - if (isShallow) { - return result; - } + result = initArrayClone(value, isDeep); + } else if (isObject(value)) { + result = initObjectClone(value, isDeep); + value = (isDeep && toString.call(result) == objectClass) ? value : result; } - else { - if (!isObject(value)) { - return value; - } - var className = toString.call(value); - if (!cloneableClasses[className]) { - return value; - } - var isArgs = className == argsClass, - isObj = !isArgs && className == objectClass; - - if (isShallow && (isArgs || isObj)) { - result = baseAssign({}, value); - if (isObj) { - return result; - } - } - var Ctor = value.constructor; - if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { - Ctor = Object; - } - if (isDeep && (isArgs || isObj)) { - result = new Ctor; - } - else { - switch (className) { - case arrayBufferClass: - return cloneBuffer(value); - - case boolClass: - case dateClass: - return new Ctor(+value); - - case float32Class: case float64Class: - case int8Class: case int16Class: case int32Class: - case uint8Class: case uint8ClampedClass: case uint16Class: case uint32Class: - var buffer = value.buffer; - return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, value.byteOffset, value.length); - - case numberClass: - case stringClass: - return new Ctor(value); - - case regexpClass: - result = Ctor(value.source, reFlags.exec(value)); - result.lastIndex = value.lastIndex; - return result; - } - } - } - if (isArgs) { - result.length = value.length; - } - if (isShallow) { + if (!isDeep || result === value) { return result; } // check for circular references and return corresponding clone @@ -1371,85 +1352,6 @@ }()); } - /** - * The base implementation of `createWrapper` which creates the wrapper and - * sets its metadata. - * - * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new function. - */ - function baseCreateWrapper(data) { - var bitmask = data[1]; - if (bitmask == BIND_FLAG) { - return setData(createBindWrapper(data), data); - } - var partialHolders = data[5]; - if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { - return setData(createPartialWrapper(data), data); - } - var func = data[0], - arity = data[2], - thisArg = data[3], - partialArgs = data[4], - partialRightArgs = data[6], - partialRightHolders = data[7]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isCurry = bitmask & CURRY_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG, - isCurryBound = bitmask & CURRY_BOUND_FLAG; - - var Ctor = !isBindKey && createCtorWrapper(func), - key = func; - - var wrapper = function() { - var length = arguments.length, - index = length, - args = Array(length); - - while (index--) { - args[index] = arguments[index]; - } - if (partialArgs) { - args = composeArgs(partialArgs, partialHolders, args); - } - if (partialRightArgs) { - args = composeArgsRight(partialRightArgs, partialRightHolders, args); - } - if (isCurry || isCurryRight) { - var placeholder = wrapper.placeholder, - newPartialHolders = replaceHolders(args, placeholder); - - length -= newPartialHolders.length; - - if (length < arity) { - bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); - bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); - - if (!isCurryBound) { - bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); - } - var newData = [func, bitmask, nativeMax(arity - length, 0), thisArg, null, null]; - newData[isCurry ? 4 : 6] = args; - newData[isCurry ? 5 : 7] = newPartialHolders; - - var result = baseCreateWrapper(newData); - result.placeholder = placeholder; - return result; - } - } - var thisBinding = isBind ? thisArg : this; - if (isBindKey) { - func = thisBinding[key]; - } - return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); - }; - - return setData(wrapper, data); - } - /** * The base implementation of `_.curry` and `_.curryRight` which handles * resolving the default arity of `func`. @@ -1462,9 +1364,9 @@ */ function baseCurry(func, bitmask, arity) { if (typeof arity != 'number') { - arity = +arity || (func ? func.length : 0); + arity = arity == null ? (func ? func.length : 0) : nativeMax(+arity || 0, 0); } - return createWrapper([func, bitmask, arity]); + return createWrapper(func, bitmask, arity); } /** @@ -1497,7 +1399,7 @@ while (++index < length) { var value = array[index]; - if (isCommon) { + if (isCommon && value === value) { var valuesIndex = valuesLength; while (valuesIndex--) { if (values[valuesIndex] === value) { @@ -1519,19 +1421,19 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iterator) { + function baseEach(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwn(collection, iterator); + return baseForOwn(collection, iteratee); } var index = -1, iterable = toIterable(collection); while (++index < length) { - if (iterator(iterable[index], index, iterable) === false) { + if (iteratee(iterable[index], index, iterable) === false) { break; } } @@ -1544,17 +1446,17 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iterator) { + function baseEachRight(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwnRight(collection, iterator); + return baseForOwnRight(collection, iteratee); } var iterable = toIterable(collection); while (length--) { - if (iterator(iterable[length], length, iterable) === false) { + if (iteratee(iterable[length], length, iterable) === false) { break; } } @@ -1668,24 +1570,24 @@ /** * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` executing `iterator` for + * over `object` properties returned by `keysFunc` executing `iteratee` for * each property. Iterator functions may exit iteration early by explicitly * returning `false`. * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iterator, keysFunc) { + function baseFor(object, iteratee, keysFunc) { var index = -1, props = keysFunc(object), length = props.length; while (++index < length) { var key = props[index]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1698,17 +1600,17 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iterator, keysFunc) { + function baseForRight(object, iteratee, keysFunc) { var props = keysFunc(object), length = props.length; while (length--) { var key = props[length]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1721,11 +1623,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForIn(object, iterator) { - return baseFor(object, iterator, keysIn); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); } /** @@ -1734,11 +1636,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwn(object, iterator) { - return baseFor(object, iterator, keys); + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } /** @@ -1747,32 +1649,32 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwnRight(object, iterator) { - return baseForRight(object, iterator, keys); + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); } /** - * The base implementation of `_.functions` which creates an array of function - * property names from those returned by `keysFunc`. + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from those provided. * * @private * @param {Object} object The object to inspect. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Array} Returns the new sorted array of property names. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the new array of filtered property names. */ - function baseFunctions(object, keysFunc) { + function baseFunctions(object, props) { var index = -1, - props = keysFunc(object), length = props.length, + resIndex = -1, result = []; while (++index < length) { var key = props[index]; if (isFunction(object[key])) { - result.push(key); + result[++resIndex] = key; } } return result; @@ -1896,7 +1798,7 @@ return (value != +value) ? other != +other // but treat `-0` vs. `+0` as not equal - : (value == 0 ? (1 / value == 1 / other) : value == +other); + : (value == 0 ? ((1 / value) == (1 / other)) : value == +other); case regexpClass: case stringClass: @@ -1999,14 +1901,14 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function baseMap(collection, iterator) { + function baseMap(collection, iteratee) { var result = []; baseEach(collection, function(value, key, collection) { - result.push(iterator(value, key, collection)); + result.push(iteratee(value, key, collection)); }); return result; } @@ -2089,51 +1991,14 @@ */ function basePartial(func, bitmask, args, holders, thisArg) { if (func) { - var data = func[EXPANDO], + var data = getData(func), arity = data ? data[2] : func.length; arity -= args.length; } - var isPartial = bitmask & PARTIAL_FLAG, - newData = [func, bitmask, arity, thisArg, null, null]; - - newData[isPartial ? 4 : 6] = args; - newData[isPartial ? 5 : 7] = holders; - return createWrapper(newData); - } - - /** - * The base implementation of `_.pick` without support for `this` binding - * and individual property name arguments. - * - * @private - * @param {Object} object The source object. - * @param {Function|string[]} predicate The function called per iteration or - * property names to pick. - * @returns {Object} Returns the new object. - */ - function basePick(object, predicate) { - var result = {}; - - if (typeof predicate == 'function') { - baseForIn(object, function(value, key, object) { - if (predicate(value, key, object)) { - result[key] = value; - } - }); - return result; - } - var index = -1, - props = predicate, - length = props.length; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - return result; + return (bitmask & PARTIAL_FLAG) + ? createWrapper(func, bitmask, arity, thisArg, args, holders) + : createWrapper(func, bitmask, arity, thisArg, null, null, args, holders); } /** @@ -2180,22 +2045,44 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} accumulator The initial value. * @param {boolean} initFromCollection Specify using the first or last element * of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iterator, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { eachFunc(collection, function(value, index, collection) { accumulator = initFromCollection ? (initFromCollection = false, value) - : iterator(accumulator, value, index, collection) + : iteratee(accumulator, value, index, collection) }); return accumulator; } + /** + * The base implementation of `setData` without support for hot loop detection. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ + function baseSetData(func, data) { + metaMap.set(func, data); + return func; + } + // fallback for environments without `WeakMap` + if (!WeakMap) { + baseSetData = !defineProperty ? identity : function(func, value) { + descriptor.value = value; + defineProperty(func, EXPANDO, descriptor); + descriptor.value = null; + return func; + }; + } + /** * The base implementation of `_.some` without support for callback shorthands * or `this` binding. @@ -2223,24 +2110,24 @@ * @private * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {boolean} [retHighest=false] Specify returning the highest, instead * of the lowest, index at which a value should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ - function baseSortedIndex(array, value, iterator, retHighest) { + function baseSortedIndex(array, value, iteratee, retHighest) { var low = 0, high = array ? array.length : low; - value = iterator(value); + value = iteratee(value); var hintNum = typeof value == 'number' || (value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number'); while (low < high) { var mid = (low + high) >>> 1, - computed = iterator(array[mid]), - setLow = retHighest ? computed <= value : computed < value; + computed = iteratee(array[mid]), + setLow = retHighest ? (computed <= value) : (computed < value); if (hintNum && typeof computed != 'undefined') { computed = +computed; @@ -2261,10 +2148,10 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function baseUniq(array, iterator) { + function baseUniq(array, iteratee) { var index = -1, indexOf = getIndexOf(), length = array.length, @@ -2277,27 +2164,27 @@ var seen = createCache(); indexOf = cacheIndexOf; } else { - seen = iterator ? [] : result; + seen = iteratee ? [] : result; } outer: while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; - if (isCommon) { + if (isCommon && value === value) { var seenIndex = seen.length; while (seenIndex--) { if (seen[seenIndex] === computed) { continue outer; } } - if (iterator) { + if (iteratee) { seen.push(computed); } result.push(value); } else if (indexOf(seen, computed) < 0) { - if (iterator || isLarge) { + if (iteratee || isLarge) { seen.push(computed); } result.push(value); @@ -2328,6 +2215,36 @@ return result; } + /** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ + function bufferClone(buffer) { + return bufferSlice.call(buffer, 0); + } + if (!bufferSlice) { + // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` + bufferClone = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { + var byteLength = buffer.byteLength, + floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, + offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, + result = new ArrayBuffer(byteLength); + + if (floatLength) { + var view = new Float64Array(result, 0, floatLength); + view.set(new Float64Array(buffer, 0, floatLength)); + } + if (byteLength != offset) { + view = new Uint8Array(result, offset); + view.set(new Uint8Array(buffer, offset)); + } + return result; + }; + } + /** * Creates an array that is the composition of partially applied arguments, * placeholders, and provided arguments into a single array of arguments. @@ -2393,7 +2310,7 @@ /** * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection - * through `iterator`. The given setter function sets the keys and values of + * through `iteratee`. The given setter function sets the keys and values of * the accumulator object. If `initializer` is provided it is used to initialize * the accumulator object. * @@ -2403,9 +2320,9 @@ * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function(collection, iterator, thisArg) { + return function(collection, iteratee, thisArg) { var result = initializer ? initializer() : {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); if (isArray(collection)) { var index = -1, @@ -2413,11 +2330,11 @@ while (++index < length) { var value = collection[index]; - setter(result, value, iterator(value, index, collection), collection); + setter(result, value, iteratee(value, index, collection), collection); } } else { baseEach(collection, function(value, key, collection) { - setter(result, value, iterator(value, key, collection), collection); + setter(result, value, iteratee(value, key, collection), collection); }); } return result; @@ -2433,44 +2350,43 @@ * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { - return function(object) { - var args = arguments, - length = args.length; + return function() { + var length = arguments.length, + object = arguments[0]; if (object == null || length < 2) { return object; } // enables use as a callback for functions like `_.reduce` - var type = typeof args[2]; - if ((type == 'number' || type == 'string') && args[3] && args[3][args[2]] === args[1]) { + var type = typeof arguments[2]; + if ((type == 'number' || type == 'string') && arguments[3] && arguments[3][arguments[2]] === arguments[1]) { length = 2; } // juggle arguments - if (length > 3 && typeof args[length - 2] == 'function') { - var customizer = baseCallback(args[--length - 1], args[length--], 5); - } else if (length > 2 && typeof args[length - 1] == 'function') { - customizer = args[--length]; + 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') { + customizer = arguments[--length]; } var index = 0; while (++index < length) { - assigner(object, args[index], customizer); + assigner(object, arguments[index], customizer); } return object; }; } /** - * Creates a function that invokes the function specified in the metadata - * with its associated `this` binding. + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new bound function. + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. */ - function createBindWrapper(data) { - var func = data[0], - thisArg = data[3], - Ctor = createCtorWrapper(func); + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); function wrapper() { return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments); @@ -2515,6 +2431,77 @@ }; } + /** + * Creates a function that wraps `func` and invokes it with optional `this` + * binding of, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. + * @returns {Function} Returns the new function. + */ + function createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBind = bitmask & BIND_FLAG, + isBindKey = bitmask & BIND_KEY_FLAG, + isCurry = bitmask & CURRY_FLAG, + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + isCurryBound = bitmask & CURRY_BOUND_FLAG; + + var Ctor = !isBindKey && createCtorWrapper(func), + key = func; + + function wrapper() { + var length = arguments.length, + index = length, + args = Array(length); + + while (index--) { + args[index] = arguments[index]; + } + if (partialArgs) { + args = composeArgs(partialArgs, partialHolders, args); + } + if (partialRightArgs) { + args = composeArgsRight(partialRightArgs, partialRightHolders, args); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, + holders = replaceHolders(args, placeholder); + + length -= holders.length; + if (length < arity) { + var newArity = nativeMax(arity - length, 0), + newPartialArgs = isCurry ? args : null, + newPartialHolders = isCurry ? holders : null, + newPartialRightArgs = isCurry ? null : args, + newPartialRightHolders = isCurry ? null : holders; + + bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var result = createHybridWrapper(func, bitmask, newArity, thisArg, newPartialArgs, newPartialHolders, newPartialRightArgs, newPartialRightHolders); + result.placeholder = placeholder; + return setData(result, [func, bitmask, newArity, thisArg, newPartialArgs, newPartialHolders, newPartialRightArgs, newPartialRightHolders]); + } + } + var thisBinding = isBind ? thisArg : this; + if (isBindKey) { + func = thisBinding[key]; + } + return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); + } + return wrapper; + } + /** * Creates the pad required for `string` based on the given padding length. * The `chars` string may be truncated if the number of padding characters @@ -2539,25 +2526,25 @@ } /** - * Creates a function that invokes the function specified in the metadata - * with its associated partially applied arguments and optional `this` binding. + * Creates a function that wraps `func` and invokes it with the optional `this` + * binding of `thisArg` and the `partialArgs` prepended to those provided to + * the wrapper. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. + * @param {Function} func The function to partially apply arguments to. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {Array} partialArgs An array of 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(data) { - var func = data[0], - thisArg = data[3], - partialArgs = data[4]; - - var isBind = data[1] & BIND_FLAG, + function createPartialWrapper(func, bitmask, partialArgs, thisArg) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { // avoid `arguments` object use disqualifying optimizations by // converting it to an array before passing it to `composeArgs` - var argsIndex = 0, + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partialArgs.length, @@ -2567,7 +2554,7 @@ args[leftIndex] = partialArgs[leftIndex]; } while (argsLength--) { - args[leftIndex++] = arguments[argsIndex++]; + args[leftIndex++] = arguments[++argsIndex]; } return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args); } @@ -2579,9 +2566,8 @@ * `this` binding and partially applied arguments. * * @private - * @param {Array} data The metadata array. - * @param {Function|string} data[0] The function or method name to reference. - * @param {number} data[1] The bitmask of flags to compose. + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. * The bitmask may be composed of the following flags: * 1 - `_.bind` * 2 - `_.bindKey` @@ -2590,97 +2576,80 @@ * 16 - `_.curry` or `_.curryRight` of a bound function * 32 - `_.partial` * 64 - `_.partialRight` - * @param {number} data[2] The arity of `data[0]`. - * @param {*} [data[3]] The `this` binding of `data[0]`. - * @param {Array} [data[4]] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [data[5]] An array of `data[4]` placeholder indexes. - * @param {Array} [data[6]] An array of arguments to append to those - * provided to the new function. - * @param {Array} [data[7]] An array of `data[6]` placeholder indexes. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. * @returns {Function} Returns the new function. */ - function createWrapper(data) { - var func = data[0], - bitmask = data[1]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isPartial = bitmask & PARTIAL_FLAG, - isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; - + function createWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBindKey = bitmask & BIND_KEY_FLAG; if (!isBindKey && !isFunction(func)) { throw new TypeError(FUNC_ERROR_TEXT); } - var arity = data[2], - partialArgs = data[4], - partialRightArgs = data[6]; - + var isPartial = bitmask & PARTIAL_FLAG; if (isPartial && !partialArgs.length) { + bitmask &= ~PARTIAL_FLAG; isPartial = false; - data[1] = (bitmask &= ~PARTIAL_FLAG); - data[4] = data[5] = partialArgs = null; + partialArgs = partialHolders = null; } + var isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; if (isPartialRight && !partialRightArgs.length) { + bitmask &= ~PARTIAL_RIGHT_FLAG; isPartialRight = false; - data[1] = (bitmask &= ~PARTIAL_RIGHT_FLAG); - data[6] = data[7] = partialRightArgs = null; + partialRightArgs = partialRightHolders = null; } - var funcData = !isBindKey && func[EXPANDO]; - if (funcData && funcData !== true) { - // shallow clone `funcData` - funcData = slice(funcData); + var data = (data = !isBindKey && getData(func)) && data !== true && data; + if (data) { + var funcBitmask = data[1], + funcIsBind = funcBitmask & BIND_FLAG, + isBind = bitmask & BIND_FLAG; - // clone partial left arguments - if (funcData[4]) { - funcData[4] = slice(funcData[4]); - funcData[5] = slice(funcData[5]); + // use metadata `func` and merge bitmasks + func = data[0]; + bitmask |= funcBitmask; + + // use metadata `arity` if not provided + if (arity == null) { + arity = data[2]; } - // clone partial right arguments - if (funcData[6]) { - funcData[6] = slice(funcData[6]); - funcData[7] = slice(funcData[7]); - } - // set arity if provided - if (typeof arity == 'number') { - funcData[2] = arity; - } - // set `thisArg` if not previously bound - var bound = funcData[1] & BIND_FLAG; - if (isBind && !bound) { - funcData[3] = data[3]; + // use metadata `thisArg` if available + if (funcIsBind) { + thisArg = data[3]; } // set if currying a bound function - if (!isBind && bound) { + if (!isBind && funcIsBind) { bitmask |= CURRY_BOUND_FLAG; } // append partial left arguments - if (isPartial) { - var funcPartialArgs = funcData[4]; - if (funcPartialArgs) { - funcPartialArgs = composeArgs(funcPartialArgs, funcData[5], partialArgs); - } - funcData[4] = funcPartialArgs || partialArgs; - funcData[5] = funcPartialArgs ? replaceHolders(funcPartialArgs, PLACEHOLDER) : data[5]; + var funcArgs = data[4]; + if (funcArgs) { + var funcHolders = data[5]; + partialArgs = isPartial ? composeArgs(funcArgs, funcHolders, partialArgs) : baseSlice(funcArgs); + partialHolders = isPartial ? replaceHolders(partialArgs, PLACEHOLDER) : baseSlice(funcHolders); } // prepend partial right arguments - if (isPartialRight) { - var funcPartialRightArgs = funcData[6]; - if (funcPartialRightArgs) { - funcPartialRightArgs = composeArgsRight(funcPartialRightArgs, funcData[7], partialRightArgs); - } - funcData[6] = funcPartialRightArgs || partialRightArgs; - funcData[7] = funcPartialRightArgs ? replaceHolders(funcPartialRightArgs, PLACEHOLDER) : data[7]; + funcArgs = data[6]; + if (funcArgs) { + funcHolders = data[7]; + partialRightArgs = isPartialRight ? composeArgsRight(funcArgs, funcHolders, partialRightArgs) : baseSlice(funcArgs); + partialRightHolders = isPartialRight ? replaceHolders(partialRightArgs, PLACEHOLDER) : baseSlice(funcHolders); } - // merge flags - funcData[1] |= bitmask; - return createWrapper(funcData); } if (arity == null) { arity = isBindKey ? 0 : func.length; } - data[2] = nativeMax(arity, 0); - return baseCreateWrapper(data); + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(func, thisArg); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { + result = createPartialWrapper(func, bitmask, partialArgs, thisArg); + } else { + result = createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders); + } + var setter = data ? baseSetData : setData; + return setter(result, [func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders]); } /** @@ -2695,7 +2664,24 @@ function getCallback(func, thisArg, argCount) { var result = lodash.callback || callback; result = result === callback ? baseCallback : result; - return arguments.length ? result(func, thisArg, argCount) : result; + return argCount ? result(func, thisArg, argCount) : result; + } + + /** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ + function getData(func) { + return metaMap.get(func); + } + // fallback for environments without `WeakMap` + if (!WeakMap) { + getData = !defineProperty ? noop : function(func) { + return func[EXPANDO]; + }; } /** @@ -2713,6 +2699,84 @@ return collection ? result(collection, target, fromIndex) : result; } + /** + * Initializes an array clone. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @returns {*} Returns the initialized clone value. + */ + function initArrayClone(array, isDeep) { + var index = -1, + length = array.length, + result = array.constructor(length); + + if (!isDeep) { + while (++index < length) { + result[index] = array[index]; + } + } + // 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; + } + return result; + } + + /** + * Initializes an object clone. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep=false] Specify a deep clone. + * @returns {*} Returns the initialized clone value. + */ + function initObjectClone(object, isDeep) { + var className = toString.call(object); + if (!cloneableClasses[className]) { + return object; + } + var Ctor = object.constructor, + isArgs = className == argsClass, + isObj = className == objectClass; + + if (isObj && !(isFunction(Ctor) && (Ctor instanceof Ctor))) { + Ctor = Object; + } + if (isArgs || isObj) { + var result = isDeep ? new Ctor : baseAssign(new Ctor, object); + if (isArgs) { + result.length = object.length; + } + return result; + } + switch (className) { + case arrayBufferClass: + return bufferClone(object); + + case boolClass: + case dateClass: + return new Ctor(+object); + + case float32Class: case float64Class: + case int8Class: case int16Class: case int32Class: + case uint8Class: case uint8ClampedClass: case uint16Class: case uint32Class: + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberClass: + case stringClass: + return new Ctor(object); + + case regexpClass: + result = Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; + } + /** * Checks if `value` is an array-like object. * @@ -2725,20 +2789,6 @@ arrayLikeClasses[toString.call(value)]) || false; } - /** - * Checks if `value` is a native function. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. - */ - function isNative(value) { - var type = typeof value; - return type == 'function' - ? reNative.test(fnToString.call(value)) - : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; - } - /** * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * @@ -2748,37 +2798,50 @@ * equality comparisons, else `false`. */ function isStrictComparable(value) { - return value === value && (value === 0 ? (1 / value > 0) : !isObject(value)); + return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); } /** - * Creates a clone of the given array buffer. + * A specialized version of `_.pick` that picks `object` properties + * specified by the `props` array. * * @private - * @param {ArrayBuffer} buffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. + * @param {Object} object The source object. + * @param {string[]} props The property names to pick. + * @returns {Object} Returns the new object. */ - function cloneBuffer(buffer) { - return bufferSlice.call(buffer, 0); - } - if (!bufferSlice) { - // PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array` - cloneBuffer = !(ArrayBuffer && Uint8Array) ? identity : function(buffer) { - var byteLength = buffer.byteLength, - floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, - offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, - result = new ArrayBuffer(byteLength); + function pickByArray(object, props) { + var index = -1, + length = props.length, + result = {}; - if (floatLength) { - var view = new Float64Array(result, 0, floatLength); - view.set(new Float64Array(buffer, 0, floatLength)); + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; } - if (byteLength != offset) { - view = new Uint8Array(result, offset); - view.set(new Uint8Array(buffer, offset)); + } + return result; + } + + /** + * A specialized version of `_.pick` that picks `object` properties + * the predicate returns truthy for. + * + * @private + * @param {Object} object The source object. + * @param {Function} predicate The function called per iteration. + * @returns {Object} Returns the new object. + */ + function pickByCallback(object, predicate) { + var result = {}; + + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; } - return result; - }; + }); + return result; } /** @@ -2793,31 +2856,49 @@ function replaceHolders(array, placeholder) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { if (array[index] === placeholder) { array[index] = PLACEHOLDER; - result.push(index); + result[++resIndex] = index; } } return result; } /** - * Sets wrapper metadata on a given function. + * Sets metadata for `func`. + * + * **Note**: If this function becomes hot, i.e. is called a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses. * * @private - * @param {Function} func The function to set data on. - * @param {Array} value The data array to set. + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. * @returns {Function} Returns `func`. */ - var setData = !defineProperty ? identity : function(func, value) { - descriptor.value = value; - defineProperty(func, EXPANDO, descriptor); - descriptor.value = null; - return func; - }; + var setData = (function() { + var count = 0, + lastCalled = 0; + + return function(key, value) { + var stamp = now ? now() : 0, + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count > HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); + }; + }()); /** * A fallback implementation of `_.isPlainObject` which checks if `value` @@ -2883,22 +2964,23 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function sortedUniq(array, iterator) { + function sortedUniq(array, iteratee) { var seen, index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (!index || seen !== computed) { seen = computed; - result.push(value); + result[++resIndex] = value; } } return result; @@ -2937,7 +3019,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements split into groups the length of `chunkSize`. + * Creates an array of elements split into groups the length of `size`. * If `collection` can't be split evenly, the final chunk will be the remaining * elements. * @@ -2945,7 +3027,7 @@ * @memberOf _ * @category Array * @param {Array} array The array to process. - * @param {numer} [chunkSize=1] The size of each chunk. + * @param {numer} [size=1] The length of each chunk. * @returns {Array} Returns the new array containing chunks. * @example * @@ -2955,14 +3037,15 @@ * _.chunk(['a', 'b', 'c', 'd'], 3); * // => [['a', 'b', 'c'], ['d']] */ - function chunk(array, chunkSize) { + function chunk(array, size) { var index = 0, length = array ? array.length : 0, + resIndex = -1, result = []; - chunkSize = nativeMax(+chunkSize || 1, 1); + size = typeof size == 'undefined' ? 1 : nativeMax(+size || 1, 1); while (index < length) { - result.push(slice(array, index, (index += chunkSize))); + result[++resIndex] = slice(array, index, (index += size)); } return result; } @@ -2997,8 +3080,12 @@ } /** - * Creates an array excluding all values of the provided arrays using strict - * equality for comparisons, i.e. `===`. + * Creates an array excluding all values of the provided arrays using + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3131,7 +3218,7 @@ index = length; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) { } + while (index-- && predicate(array[index], index, array)) {} return slice(array, 0, index + 1); } @@ -3180,7 +3267,7 @@ length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) { } + while (++index < length && predicate(array[index], index, array)) {} return slice(array, index); } @@ -3365,10 +3452,14 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` - * using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, + * 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. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @category Array @@ -3422,7 +3513,11 @@ /** * Creates an array of unique values present in all provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3530,8 +3625,10 @@ index = sortedLastIndex(array, value) - 1; return (length && array[index] === value) ? index : -1; } + var isReflexive = value === value; while (index--) { - if (array[index] === value) { + var other = array[index]; + if ((isReflexive ? other === value : other !== other)) { return index; } } @@ -3539,10 +3636,14 @@ } /** - * Removes all provided values from `array` using strict equality for - * comparisons, i.e. `===`. + * Removes all provided values from `array` using `SameValueZero` for equality + * comparisons. * - * Note: Unlike `_.without`, this method mutates `array`. + * **Note:** Unlike `_.without`, this method mutates `array`. + * + * `SameValueZero` is like strict equality, e.g. `===`, except that `NaN` matches + * `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3557,20 +3658,18 @@ * console.log(array); * // => [1, 1] */ - function pull(array) { - var argsIndex = 0, - argsLength = arguments.length, - length = array ? array.length : 0; + function pull() { + var array = arguments[0], + index = 0, + indexOf = getIndexOf(), + length = arguments.length; - while (++argsIndex < argsLength) { - var index = -1, - value = arguments[argsIndex]; + while (++index < length) { + var fromIndex = 0, + value = arguments[index]; - while (++index < length) { - if (array[index] === value) { - splice.call(array, index--, 1); - length--; - } + while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { + splice.call(array, fromIndex, 1); } } return array; @@ -3581,7 +3680,7 @@ * returns an array of the removed elements. Indexes may be specified as an * array of indexes or as individual arguments. * - * Note: Unlike `_.at`, this method mutates `array`. + * **Note:** Unlike `_.at`, this method mutates `array`. * * @static * @memberOf _ @@ -3617,7 +3716,7 @@ * returns `true` for elements that have the properties of the given object, * else `false`. * - * Note: Unlike `_.filter`, this method mutates `array`. + * **Note:** Unlike `_.filter`, this method mutates `array`. * * @static * @memberOf _ @@ -3677,7 +3776,7 @@ /** * Slices `array` from the `start` index up to, but not including, the `end` index. * - * Note: This function is used instead of `Array#slice` to support node lists + * **Note:** This function is used instead of `Array#slice` to support node lists * in IE < 9 and to ensure dense arrays are returned. * * @static @@ -3700,6 +3799,9 @@ if (end < 0) { end += length; } + if (end && end == length && !start) { + return baseSlice(array); + } length = start > end ? 0 : (end - start); var result = Array(length); @@ -3712,14 +3814,14 @@ /** * Uses a binary search to determine the lowest index at which a value should * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iterator function is provided it is executed for `value` - * and each element of `array` to compute their sort ranking. The iterator + * of the array. If an iteratee function is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The iteratee * function is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -3728,10 +3830,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3744,7 +3846,7 @@ * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; * - * // using an iterator function + * // using an iteratee function * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { * return this.data[word]; * }, dict); @@ -3754,9 +3856,9 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator); + function sortedIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee); } /** @@ -3769,10 +3871,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3780,9 +3882,9 @@ * _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); * // => 4 */ - function sortedLastIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator, true); + function sortedLastIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee, true); } /** @@ -3892,7 +3994,7 @@ index = length; predicate = getCallback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) { } + while (index-- && predicate(array[index], index, array)) {} return slice(array, index + 1); } @@ -3941,13 +4043,17 @@ length = array ? array.length : 0; predicate = getCallback(predicate, thisArg, 3); - while (++index < length && predicate(array[index], index, array)) { } + while (++index < length && predicate(array[index], index, array)) {} return slice(array, 0, index); } /** * Creates an array of unique values, in order, of the provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -3964,30 +4070,34 @@ } /** - * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a - * faster search algorithm for sorted arrays. If an iterator function is - * provided it is executed for each value in the array to generate the criterion - * by which uniqueness is computed. The `iterator` is bound to `thisArg` and - * invoked with three arguments; (value, index, array). + * Creates a duplicate-value-free version of an array using `SameValueZero` + * for equality comparisons. Providing `true` for `isSorted` performs a faster + * search algorithm for sorted arrays. If an iteratee function is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @alias unique * @category Array * @param {Array} array The array to inspect. * @param {boolean} [isSorted=false] Specify the array is sorted. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new duplicate-value-free array. * @example * @@ -3998,7 +4108,7 @@ * _.uniq([1, 1, 2], true); * // => [1, 2] * - * // using an iterator function + * // using an iteratee function * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); * // => [1, 2.5] * @@ -4006,7 +4116,7 @@ * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, iterator, thisArg) { + function uniq(array, isSorted, iteratee, thisArg) { var length = array ? array.length : 0; if (!length) { return []; @@ -4014,21 +4124,21 @@ // juggle arguments var type = typeof isSorted; if (type != 'boolean' && isSorted != null) { - thisArg = iterator; - iterator = isSorted; + thisArg = iteratee; + iteratee = isSorted; isSorted = false; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === array) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { + iteratee = null; } } - if (iterator != null) { - iterator = getCallback(iterator, thisArg, 3); + if (iteratee != null) { + iteratee = getCallback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() == baseIndexOf) - ? sortedUniq(array, iterator) - : baseUniq(array, iterator); + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); } /** @@ -4061,8 +4171,12 @@ } /** - * Creates an array excluding all provided values using strict equality for - * comparisons, i.e. `===`. + * Creates an array excluding all provided values using `SameValueZero` for + * equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -4075,8 +4189,8 @@ * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); * // => [2, 3, 4] */ - function without() { - return baseDifference(arguments[0], slice(arguments, 1)); + function without(array) { + return baseDifference(array, slice(arguments, 1)); } /** @@ -4128,7 +4242,13 @@ * // => [['fred', 30, true], ['barney', 40, false]] */ function zip() { - return unzip(arguments); + var length = arguments.length, + array = Array(length); + + while (length--) { + array[length] = arguments[length]; + } + return unzip(array); } /** @@ -4320,9 +4440,13 @@ } /** - * Checks if `value` is present in `collection` using strict equality for - * comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the - * offset from the end of the collection. + * Checks if `value` is present in `collection` using `SameValueZero` for + * equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of the collection. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -4358,28 +4482,22 @@ } else { fromIndex = 0; } - if (typeof collection == 'string' || !isArray(collection) && isString(collection)) { - if (fromIndex >= length) { - return false; - } - return nativeContains - ? nativeContains.call(collection, target, fromIndex) - : collection.indexOf(target, fromIndex) > -1; - } - return getIndexOf(collection, target, fromIndex) > -1; + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) + : (getIndexOf(collection, target, fromIndex) > -1); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding value - * of each key is the number of times the key was returned by `iterator`. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4387,10 +4505,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4449,10 +4567,10 @@ * // => false */ function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arrayEvery : baseEvery; return func(collection, predicate); } @@ -4497,9 +4615,9 @@ * // => [{ 'name': 'barney', 'age': 36 }] */ function filter(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - var func = isArray(collection) ? arrayFilter : baseFilter; + + predicate = getCallback(predicate, thisArg, 3); return func(collection, predicate); } @@ -4607,12 +4725,12 @@ } /** - * Iterates over elements of `collection` executing `iterator` for each - * element. The `iterator` is bound to `thisArg` and invoked with three arguments; + * Iterates over elements of `collection` executing `iteratee` for each + * element. The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * - * Note: As with other "Collections" methods, objects with a `length` property + * **Note:** As with other "Collections" methods, objects with a `length` property * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` * may be used for object iteration. * @@ -4621,8 +4739,8 @@ * @alias each * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * @@ -4630,12 +4748,12 @@ * // => logs each value and returns the array * * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); - * // => logs each value-key pair and returns the object (property order is not guaranteed across environments) + * // => logs each value-key pair and returns the object (property order is not guaranteed) */ - function forEach(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iterator) - : baseEach(collection, baseCallback(iterator, thisArg, 3)); + function forEach(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEach(collection, iteratee) + : baseEach(collection, baseCallback(iteratee, thisArg, 3)); } /** @@ -4647,31 +4765,31 @@ * @alias eachRight * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); * // => logs each value from right to left and returns the array */ - function forEachRight(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEachRight(collection, iterator) - : baseEachRight(collection, baseCallback(iterator, thisArg, 3)); + function forEachRight(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEachRight(collection, iteratee) + : baseEachRight(collection, baseCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding + * each element of `collection` through `iteratee`. The corresponding * value of each key is an array of the elements responsible for generating - * the key. The `iterator` is bound to `thisArg` and invoked with three + * the key. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4679,10 +4797,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4706,15 +4824,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iterator`. The corresponding value + * each element of the collection through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4722,10 +4840,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4775,13 +4893,13 @@ /** * Creates an array of values by running each element in the collection through - * `iterator`. The `iterator` is bound to `thisArg` and invoked with three + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4790,10 +4908,10 @@ * @alias collect * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new mapped array. * @example * @@ -4801,7 +4919,7 @@ * // => [3, 6, 9] * * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); - * // => [3, 6, 9] (property order is not guaranteed across environments) + * // => [3, 6, 9] (property order is not guaranteed) * * var characters = [ * { 'name': 'barney', 'age': 36 }, @@ -4812,24 +4930,24 @@ * _.map(characters, 'name'); * // => ['barney', 'fred'] */ - function map(collection, iterator, thisArg) { - iterator = getCallback(iterator, thisArg, 3); + function map(collection, iteratee, thisArg) { + iteratee = getCallback(iteratee, thisArg, 3); var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, iterator); + return func(collection, iteratee); } /** * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iterator function is provided it + * or falsey `-Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4837,10 +4955,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the maximum value. * @example * @@ -4862,20 +4980,20 @@ * _.max(characters, 'age'); * // => { 'name': 'fred', 'age': 40 }; */ - function max(collection, iterator, thisArg) { + function max(collection, iteratee, thisArg) { var computed = -Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, - isArr = noIterator && isArray(collection), + var noIteratee = iteratee == null, + isArr = noIteratee && isArray(collection), isStr = !isArr && isString(collection); - if (noIterator && !isStr) { + if (noIteratee && !isStr) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -4887,12 +5005,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIteratee && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current > computed || (current === -Infinity && current === result)) { computed = current; result = value; @@ -4904,15 +5022,15 @@ /** * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iterator function is provided it + * or falsey `Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -4920,10 +5038,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the minimum value. * @example * @@ -4945,20 +5063,20 @@ * _.min(characters, 'age'); * // => { 'name': 'barney', 'age': 36 }; */ - function min(collection, iterator, thisArg) { + function min(collection, iteratee, thisArg) { var computed = Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, - isArr = noIterator && isArray(collection), + var noIteratee = iteratee == null, + isArr = noIteratee && isArray(collection), isStr = !isArr && isString(collection); - if (noIterator && !isStr) { + if (noIteratee && !isStr) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -4970,12 +5088,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIteratee && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current < computed || (current === Infinity && current === result)) { computed = current; result = value; @@ -5058,10 +5176,10 @@ /** * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iterator`, where each successive + * each element in the collection through `iteratee`, where each successive * execution consumes the return value of the previous execution. If `accumulator` * is not provided the first element of the collection is used as the initial - * value. The `iterator` is bound to `thisArg`and invoked with four arguments; + * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * * @static @@ -5069,9 +5187,9 @@ * @alias foldl, inject * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5082,11 +5200,11 @@ * result[key] = n * 3; * return result; * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * // => { 'a': 3, 'b': 6, 'c': 9 } (property order is not guaranteed) */ - function reduce(collection, iterator, accumulator, thisArg) { + function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); } /** @@ -5098,9 +5216,9 @@ * @alias foldr * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5108,9 +5226,9 @@ * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iterator, accumulator, thisArg) { + function reduceRight(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); } /** @@ -5152,8 +5270,12 @@ * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] */ function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = getCallback(predicate, thisArg, 3); - return filter(collection, negate(predicate)); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); } /** @@ -5287,27 +5409,27 @@ * // => false */ function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = getCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arraySome : baseSome; return func(collection, predicate); } /** * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iterator`. This method performs + * running each element in a collection through `iteratee`. This method performs * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * 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 `iterator` the collection + * If an array of property names is provided for `iteratee` the collection * is sorted by each property value. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -5315,10 +5437,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [iterator=identity] The function + * @param {Array|Function|Object|string} [iteratee=identity] The function * called per iteration. If property name(s) or an object is provided it * is used to create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example * @@ -5343,28 +5465,28 @@ * _.map(_.sortBy(characters, ['name', 'age']), _.values); * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortBy(collection, iterator, thisArg) { + function sortBy(collection, iteratee, thisArg) { var index = -1, length = collection ? collection.length : 0, - multi = iterator && isArray(iterator), + multi = iteratee && isArray(iteratee), result = []; if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { result.length = length; } if (!multi) { - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); } baseEach(collection, function(value, key, collection) { if (multi) { - var length = iterator.length, + var length = iteratee.length, criteria = Array(length); while (length--) { - criteria[length] = value[iterator[length]]; + criteria[length] = value == null ? undefined : value[iteratee[length]]; } } else { - criteria = iterator(value, key, collection); + criteria = iteratee(value, key, collection); } result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); @@ -5393,7 +5515,7 @@ function toArray(collection) { var length = collection ? collection.length : 0; if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { - return slice(collection); + return baseSlice(collection); } return values(collection); } @@ -5501,7 +5623,7 @@ * and prepends any additional `bind` arguments to those provided to the bound * function. * - * Note: Unlike native `Function#bind` this method does not set the `length` + * **Note:** Unlike native `Function#bind` this method does not set the `length` * property of bound functions. * * @static @@ -5523,12 +5645,12 @@ */ function bind(func, thisArg) { if (arguments.length < 3) { - return createWrapper([func, BIND_FLAG, null, thisArg]); + return createWrapper(func, BIND_FLAG, null, thisArg); } var args = slice(arguments, 2), - partialHolders = replaceHolders(args, bind.placeholder); + holders = replaceHolders(args, bind.placeholder); - return basePartial(func, BIND_FLAG | PARTIAL_FLAG, args, partialHolders, thisArg); + return basePartial(func, BIND_FLAG | PARTIAL_FLAG, args, holders, thisArg); } /** @@ -5537,7 +5659,7 @@ * of method names. If no method names are provided all enumerable function * properties, own and inherited, of `object` are bound. * - * Note: This method does not set the `length` property of bound functions. + * **Note:** This method does not set the `length` property of bound functions. * * @static * @memberOf _ @@ -5601,12 +5723,14 @@ * // => 'hiya fred!' */ function bindKey(object, key) { - var data = [key, BIND_FLAG | BIND_KEY_FLAG, null, object]; + var bitmask = BIND_FLAG | BIND_KEY_FLAG; if (arguments.length > 2) { - var args = slice(arguments, 2); - data.push(args, replaceHolders(args, bindKey.placeholder)); + var args = slice(arguments, 2), + holders = replaceHolders(args, bindKey.placeholder); } - return createWrapper(data); + return args + ? createWrapper(key, bitmask, null, object, args, holders) + : createWrapper(key, bitmask, null, object); } /** @@ -5670,7 +5794,7 @@ * remaining `func` arguments, and so on. The arity of `func` can be specified * if `func.length` is not sufficient. * - * Note: This method does not set the `length` property of curried functions. + * **Note:** This method does not set the `length` property of curried functions. * * @static * @memberOf _ @@ -5703,7 +5827,7 @@ * This method is like `_.curry` except that arguments are applied to `func` * in the manner of `_.partialRight` instead of `_.partial`. * - * Note: This method does not set the `length` property of curried functions. + * **Note:** This method does not set the `length` property of curried functions. * * @static * @memberOf _ @@ -5740,7 +5864,7 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * @@ -6061,7 +6185,7 @@ * prepended to those provided to the new function. This method is similar to * `_.bind` except it does **not** alter the `this` binding. * - * Note: This method does not set the `length` property of partially applied + * **Note:** This method does not set the `length` property of partially applied * functions. * * @static @@ -6079,16 +6203,16 @@ */ function partial(func) { var args = slice(arguments, 1), - partialHolders = replaceHolders(args, partial.placeholder); + holders = replaceHolders(args, partial.placeholder); - return basePartial(func, PARTIAL_FLAG, args, partialHolders); + return basePartial(func, PARTIAL_FLAG, args, holders); } /** * 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 + * **Note:** This method does not set the `length` property of partially applied * functions. * * @static @@ -6117,9 +6241,9 @@ */ function partialRight(func) { var args = slice(arguments, 1), - partialHolders = replaceHolders(args, partialRight.placeholder); + holders = replaceHolders(args, partialRight.placeholder); - return basePartial(func, PARTIAL_RIGHT_FLAG, args, partialHolders); + return basePartial(func, PARTIAL_RIGHT_FLAG, args, holders); } /** @@ -6130,7 +6254,7 @@ * Subsequent calls to the throttled function return the result of the last * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * @@ -6243,7 +6367,7 @@ * cloning is handled by the method instead. The `customizer` is bound to * `thisArg` and invoked with two argument; (value, index|key). * - * Note: This method is loosely based on the structured clone algorithm. Functions + * **Note:** This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and * objects created by constructors other than `Object` are cloned to plain `Object` objects. * See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) @@ -6306,7 +6430,7 @@ * is handled by the method instead. The `customizer` is bound to `thisArg` * and invoked with two argument; (value, index|key). * - * Note: This method is loosely based on the structured clone algorithm. Functions + * **Note:** This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and * objects created by constructors other than `Object` are cloned to plain `Object` objects. * See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) @@ -6388,7 +6512,7 @@ * object for all destination properties that resolve to `undefined`. Once a * property is set, additional defaults of the same property are ignored. * - * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) + * **Note:** See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. * * @static @@ -6406,7 +6530,7 @@ if (object == null) { return object; } - var args = slice(arguments); + var args = baseSlice(arguments); args.push(assignDefaults); return assign.apply(undefined, args); } @@ -6442,7 +6566,7 @@ * _.findKey(characters, function(chr) { * return chr.age < 40; * }); - * // => 'barney' (property order is not guaranteed across environments) + * // => 'barney' (property order is not guaranteed) * * // using "_.where" callback shorthand * _.findKey(characters, { 'age': 1 }); @@ -6505,7 +6629,7 @@ /** * Iterates over own and inherited enumerable properties of an object executing - * `iterator` for each property. The `iterator` is bound to `thisArg` and invoked + * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, key, object). Iterator functions may exit * iteration early by explicitly returning `false`. * @@ -6513,8 +6637,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6528,13 +6652,13 @@ * _.forIn(new Shape, function(value, key) { * console.log(key); * }); - * // => logs 'x', 'y', and 'z' (property order is not guaranteed across environments) + * // => logs 'x', 'y', and 'z' (property order is not guaranteed) */ - function forIn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forIn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseFor(object, iterator, keysIn); + return baseFor(object, iteratee, keysIn); } /** @@ -6545,8 +6669,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6562,14 +6686,14 @@ * }); * // => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z' */ - function forInRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keysIn); + function forInRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keysIn); } /** - * Iterates over own enumerable properties of an object executing `iterator` - * for each property. The `iterator` is bound to `thisArg` and invoked with + * Iterates over own enumerable properties of an object executing `iteratee` + * for each property. The `iteratee` is bound to `thisArg` and invoked with * three arguments; (value, key, object). Iterator functions may exit iteration * early by explicitly returning `false`. * @@ -6577,21 +6701,21 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { * console.log(key); * }); - * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) + * // => logs '0', '1', and 'length' (property order is not guaranteed) */ - function forOwn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forOwn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseForOwn(object, iterator); + return baseForOwn(object, iteratee); } /** @@ -6602,8 +6726,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6612,9 +6736,9 @@ * }); * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' */ - function forOwnRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keys); + function forOwnRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keys); } /** @@ -6626,14 +6750,14 @@ * @alias methods * @category Object * @param {Object} object The object to inspect. - * @returns {Array} Returns the new sorted array of property names. + * @returns {Array} Returns the new array of property names. * @example * * _.functions(_); * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] */ function functions(object) { - return baseFunctions(object, keysIn); + return baseFunctions(object, keysIn(object)); } /** @@ -6862,7 +6986,7 @@ * instead. The `customizer` is bound to `thisArg` and invoked with three * arguments; (value, other, key). * - * Note: This method supports comparing arrays, booleans, `Date` objects, + * **Note:** This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes * are **not** supported. Provide a customizer function to extend support * for comparing other values. @@ -6925,7 +7049,7 @@ /** * Checks if `value` is a finite primitive number. * - * Note: This method is based on ES6 `Number.isFinite`. See the + * **Note:** This method is based on ES6 `Number.isFinite`. See the * [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) * for more details. * @@ -6981,7 +7105,7 @@ * Checks if `value` is the language type of `Object`. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * - * Note: See the [ES5 spec](http://es5.github.io/#x8) for more details. + * **Note:** See the [ES5 spec](http://es5.github.io/#x8) for more details. * * @static * @memberOf _ @@ -7009,7 +7133,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which returns `true` + * **Note:** This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -7038,6 +7162,27 @@ return isNumber(value) && value != +value; } + /** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Object + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + */ + function isNative(value) { + if (isFunction(value)) { + return reNative.test(fnToString.call(value)); + } + if (value && typeof value == 'object') { + return !('constructor' in value) && isHostObject(value) + ? reNative.test(value) + : reHostCtor.test(toString.call(value)); + } + return false; + } + /** * Checks if `value` is `null`. * @@ -7061,7 +7206,7 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * Note: To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified * as numbers, use the `_.isFinite` method. * * @static @@ -7090,7 +7235,7 @@ * Checks if `value` is an object created by the `Object` constructor or has * a `[[Prototype]]` of `null`. * - * Note: This method assumes objects created by the `Object` constructor + * **Note:** This method assumes objects created by the `Object` constructor * have no inherited enumerable properties. * * @static @@ -7208,7 +7353,7 @@ * Shape.prototype.z = 0; * * _.keys(new Shape); - * // => ['x', 'y'] (property order is not guaranteed across environments) + * // => ['x', 'y'] (property order is not guaranteed) */ var keys = !nativeKeys ? shimKeys : function(object) { object = toObject(object); @@ -7241,7 +7386,7 @@ * Shape.prototype.z = 0; * * _.keysIn(new Shape); - * // => ['x', 'y', 'z'] (property order is not guaranteed across environments) + * // => ['x', 'y', 'z'] (property order is not guaranteed) */ function keysIn(object) { if (object == null) { @@ -7275,14 +7420,14 @@ /** * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iterator`. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * running each own enumerable property of `object` through `iteratee`. The + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, key, object). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -7290,10 +7435,10 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the new mapped object. * @example * @@ -7309,12 +7454,12 @@ * _.mapValues(characters, 'age'); * // => { 'fred': 40, 'pebbles': 1 } */ - function mapValues(object, iterator, thisArg) { + function mapValues(object, iteratee, thisArg) { var result = {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); baseForOwn(object, function(value, key, object) { - result[key] = iterator(value, key, object); + result[key] = iteratee(value, key, object); }); return result; } @@ -7403,11 +7548,15 @@ if (object == null) { return {}; } - if (typeof predicate == 'function') { - return basePick(object, negate(getCallback(predicate, thisArg, 3))); + var iterable = toObject(object); + if (typeof predicate != 'function') { + var props = arrayMap(baseFlatten(arguments, false, false, 1), String); + return pickByArray(iterable, baseDifference(keysIn(iterable), props)); } - var omitProps = baseFlatten(arguments, false, false, 1); - return basePick(toObject(object), baseDifference(keysIn(object), arrayMap(omitProps, String))); + predicate = getCallback(predicate, thisArg, 3); + return pickByCallback(iterable, function(value, key, object) { + return !predicate(value, key, object); + }); } /** @@ -7422,7 +7571,7 @@ * @example * * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) + * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed) */ function pairs(object) { var index = -1, @@ -7468,18 +7617,17 @@ if (object == null) { return {}; } - return basePick(toObject(object), - typeof predicate == 'function' - ? getCallback(predicate, thisArg, 3) - : baseFlatten(arguments, false, false, 1) - ); + var iterable = toObject(object); + return typeof predicate == 'function' + ? pickByCallback(iterable, getCallback(predicate, thisArg, 3)) + : pickByArray(iterable, baseFlatten(arguments, false, false, 1)); } /** * An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own - * enumerable properties through `iterator`, with each execution potentially - * mutating the `accumulator` object. The `iterator` is bound to `thisArg` + * enumerable properties through `iteratee`, with each execution potentially + * mutating the `accumulator` object. The `iteratee` is bound to `thisArg` * and invoked with four arguments; (accumulator, value, key, object). Iterator * functions may exit iteration early by explicitly returning `false`. * @@ -7487,9 +7635,9 @@ * @memberOf _ * @category Object * @param {Array|Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -7506,7 +7654,7 @@ * }); * // => { 'a': 3, 'b': 6, 'c': 9 } */ - function transform(object, iterator, accumulator, thisArg) { + function transform(object, iteratee, accumulator, thisArg) { var isArr = isArrayLike(object); if (accumulator == null) { @@ -7520,10 +7668,10 @@ accumulator = baseCreate(proto); } } - if (iterator) { - iterator = getCallback(iterator, thisArg, 4); + if (iteratee) { + iteratee = getCallback(iteratee, thisArg, 4); (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iterator(accumulator, value, index, object); + return iteratee(accumulator, value, index, object); }); } return accumulator; @@ -7547,7 +7695,7 @@ * Shape.prototype.z = 0; * * _.values(new Shape(2, 1)); - * // => [2, 1] (property order is not guaranteed across environments) + * // => [2, 1] (property order is not guaranteed) */ function values(object) { return baseValues(object, keys); @@ -7572,7 +7720,7 @@ * Shape.prototype.z = 0; * * _.valuesIn(new Shape(2, 1)); - * // => [2, 1, 0] (property order is not guaranteed across environments) + * // => [2, 1, 0] (property order is not guaranteed) */ function valuesIn(object) { return baseValues(object, keysIn); @@ -7663,7 +7811,7 @@ * Converts the characters "&", "<", ">", '"', and "'" in `string` to * their corresponding HTML entities. * - * Note: No other characters are escaped. To escape additional characters + * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * * When working with HTML you should always quote attribute values to reduce @@ -7930,7 +8078,7 @@ * properties may be accessed as free variables in the template. If a setting * object is provided it overrides `_.templateSettings` for the template. * - * Note: In the development build `_.template` utilizes sourceURLs for easier debugging. + * **Note:** In the development build `_.template` utilizes sourceURLs for easier debugging. * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * @@ -8292,7 +8440,7 @@ * `&`, `<`, `>`, `"`, and `'` in `string` to their * corresponding characters. * - * Note: No other HTML entities are unescaped. To unescape additional HTML + * **Note:** No other HTML entities are unescaped. To unescape additional HTML * entities use a third-party library like [_he_](http://mths.be/he). * * @static @@ -8350,6 +8498,7 @@ * * @static * @memberOf _ + * @alias iteratee * @category Utility * @param {*} [func=identity] The value to convert to a callback. * @param {*} [thisArg] The `this` binding of the created callback. @@ -8466,7 +8615,7 @@ var isStrict = isStrictComparable(value); flags[index] = isStrict; - vals[index] = isStrict ? value : baseClone(value, false); + vals[index] = isStrict ? value : baseClone(value); } return function(object) { index = length; @@ -8523,16 +8672,20 @@ */ function mixin(object, source, options) { var chain = true, - methodNames = source && baseFunctions(source, keys); + isObj = isObject(source), + noOpts = options == null, + props = noOpts && isObj && keys(source), + methodNames = props && baseFunctions(source, props); - if (!source || (!options && !methodNames.length)) { - if (options == null) { + if ((props && props.length && !methodNames.length) || (noOpts && !isObj)) { + if (noOpts) { options = source; } + methodNames = false; source = object; object = this; - methodNames = baseFunctions(source, keys); } + methodNames || (methodNames = baseFunctions(source, keys(source))); if (options === false) { chain = false; } else if (isObject(options) && 'chain' in options) { @@ -8540,7 +8693,7 @@ } var index = -1, isFunc = isFunction(object), - length = methodNames ? methodNames.length : 0; + length = methodNames.length; while (++index < length) { var methodName = methodNames[index], @@ -8624,7 +8777,7 @@ * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, * in which case a `radix` of `16` is used. * - * Note: This method avoids differences in native ES3 and ES5 `parseInt` + * **Note:** This method avoids differences in native ES3 and ES5 `parseInt` * implementations. See the [ES5 spec](http://es5.github.io/#E) * for more details. * @@ -8852,16 +9005,16 @@ } /** - * Executes the iterator function `n` times, returning an array of the results - * of each execution. The `iterator` is bound to `thisArg` and invoked with + * Executes the iteratee function `n` times, returning an array of the results + * of each execution. The `iteratee` is bound to `thisArg` and invoked with * one argument; (index). * * @static * @memberOf _ * @category Utility - * @param {number} n The number of times to execute `iterator`. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {number} n The number of times to execute `iteratee`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the array of results. * @example * @@ -8874,18 +9027,18 @@ * _.times(3, function(n) { this.cast(n); }, mage); * // => also calls `mage.castSpell(n)` three times */ - function times(n, iterator, thisArg) { + function times(n, iteratee, thisArg) { n = nativeIsFinite(n = +n) && n > -1 ? n : 0; - iterator = baseCallback(iterator, thisArg, 1); + iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { - result[index] = iterator(index); + result[index] = iteratee(index); } else { - iterator(index); + iteratee(index); } } return result; @@ -9016,6 +9169,7 @@ lodash.each = forEach; lodash.eachRight = forEachRight; lodash.extend = assign; + lodash.iteratee = callback; lodash.methods = functions; lodash.object = zipObject; lodash.select = filter; @@ -9060,6 +9214,7 @@ lodash.isFinite = isFinite; lodash.isFunction = isFunction; lodash.isNaN = isNaN; + lodash.isNative = isNative; lodash.isNull = isNull; lodash.isNumber = isNumber; lodash.isObject = isObject; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index c1771afb5..93c5c3717 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,69 +3,70 @@ * Lo-Dash 3.0.0-pre (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")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 g(n){for(var t=-1,r=n.length;++ti(t,a)&&c.push(a);return c}function Mt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>S)return Xt(n,t);for(var e=-1,u=kr(n);++e=r||r>S)return Gt(n,t);for(var e=kr(n);r--&&false!==t(e[r],r,e););return n}function qt(n,t){var r=true;return Mt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Pt(n,t){var r=[];return Mt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Zt(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0 -}),u}function Kt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e>>1,a=r(n[f]),c=e?a<=t:ao(l,s)&&((t||a)&&l.push(s),c.push(p))}return c}function lr(n,t){for(var r=-1,e=t(n),u=e.length,o=Ce(u);++re)return t;var u=typeof r[2];if("number"!=u&&"string"!=u||!r[3]||r[3][r[2]]!==r[1]||(e=2),3e?vu(u+e,0):e||0;else if(e)return e=Nr(n,t),u&&n[e]===t?e:-1;return r(n,t,e)}function Ur(n){return Wr(n,1)}function Wr(n,t,r){var e=-1,u=n?n.length:0;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t,r=Ce(u);++er?vu(e+r,0):r||0:0,typeof n=="string"||!Cu(n)&&me(n)?ro&&(o=f);else t=i&&f?u:br(t,r,3),Mt(n,function(n,r,u){r=t(n,r,u),(r>e||-1/0===r&&r===o)&&(e=r,o=n)});return o}function Xr(n,t){return Yr(n,Se(t))}function Gr(n,t,r,e){return(Cu(n)?It:ir)(n,br(t,e,4),r,3>arguments.length,Mt)}function Hr(n,t,r,e){return(Cu(n)?Rt:ir)(n,br(t,e,4),r,3>arguments.length,zt)}function Qr(n){n=kr(n);for(var t=-1,r=n.length,e=Ce(r);++targuments.length)return _r([n,b,null,t]);var r=Wr(arguments,2),e=Or(r,re.placeholder);return er(n,b|E,r,e,t)}function ee(n,t){var r=[t,b|w,null,n];if(2=r||r>t?(f&&He(f),r=s,f=p=s=m,r&&(h=Bu(),a=n.apply(l,i),p||f||(i=l=null))):p=ou(e,r)}function u(){p&&He(p),f=p=s=m,(v||g!==t)&&(h=Bu(),a=n.apply(l,i),p||f||(i=l=null))}function o(){if(i=arguments,c=Bu(),l=this,s=v&&(p||!y),false===g)var r=y&&!p;else{f||y||(h=c);var o=g-(c-h),d=0>=o||o>g;d?(f&&(f=He(f)),h=c,a=n.apply(l,i)):f||(f=ou(u,o))}return d&&p?p=He(p):p||t===g||(p=ou(e,t)),r&&(d=true,a=n.apply(l,i)),!d||p||f||(i=l=null),a -}var i,f,a,c,l,p,s,h=0,g=false,v=true;if(!ge(n))throw new De(R);if(t=0>t?0:t,true===r)var y=true,v=false;else ve(r)&&(y=r.leading,g="maxWait"in r&&vu(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){p&&He(p),f&&He(f),f=p=s=m},o}function fe(n){if(!ge(n))throw new De(R);return function(){return!n.apply(this,arguments)}}function ae(n){var t=Wr(arguments,1),r=Or(t,ae.placeholder);return er(n,E,t,r)}function ce(n){var t=Wr(arguments,1),r=Or(t,ce.placeholder);return er(n,O,t,r)}function le(n){return Ht(n,_e) -}function pe(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ve.call(n)==tt||false}function se(n){return n&&typeof n=="object"&&1===n.nodeType&&-1>>0,e=n.constructor,u=-1,e=e&&n===e.prototype,o=r-1,i=Ce(r),f=0t||null==n||!hu(t))return r;n=Be(n);do t%2&&(r+=n),t=Qe(t/2),n+=n;while(t);return r}function Ae(n,t){return(n=null==n?"":Be(n))?null==t?n.slice(g(n),v(n)+1):(t=Be(t),n.slice(o(n,t),i(n,t)+1)):n}function xe(n){try{return n()}catch(t){return he(t)?t:Te(t)}}function Ee(n,t){return Wt(n,t)}function Oe(n){return n}function Ie(n){var t=Uu(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(xr(u))return function(n){return null!=n&&u===n[e]&&tu.call(n,e)}}for(var o=r,i=Ce(r),f=Ce(r);o--;){var u=n[t[o]],a=xr(u); -i[o]=a,f[o]=a?u:Nt(u,false)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!tu.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!tu.call(n,t[o]):!Qt(f[o],n[t[o]],null,true))return false;return true}}function Re(n,t,r){var e=true,u=t&&Ht(t,Uu);t&&(r||u.length)||(null==r&&(r=t),t=n,n=this,u=Ht(t,Uu)),false===r?e=false:ve(r)&&"chain"in r&&(e=r.chain),r=-1;for(var o=ge(n),i=u?u.length:0;++r--n?t.apply(this,arguments):void 0}},h.assign=Su,h.at=function(t){var r=t?t.length:0; -return typeof r=="number"&&-1t?0:t)},h.dropRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),Wr(n,0,0>t?0:t)},h.dropRightWhile=function(n,t,r){var e=n?n.length:0; -for(t=br(t,r,3);e--&&t(n[e],e,n););return Wr(n,0,e+1)},h.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=br(t,r,3);++e(s?e(s,a):i(p,a))){for(t=u;--t;){var h=o[t]; -if(0>(h?e(h,a):i(n[t],a)))continue n}s&&s.push(a),p.push(a)}return p},h.invert=function(n,t){for(var r=-1,e=Uu(n),u=e.length,o={};++rt?0:t)},h.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),Wr(n,0>t?0:t)},h.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=br(t,r,3);e--&&t(n[e],e,n););return Wr(n,e+1)},h.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=br(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},h.escape=function(n){return n=null==n?"":Be(n),$.lastIndex=0,$.test(n)?n.replace($,p):n -},h.escapeRegExp=we,h.every=qr,h.find=Zr,h.findIndex=Cr,h.findKey=function(n,t,r){return t=br(t,r,3),Zt(n,t,Xt,true)},h.findLast=function(n,t,r){return t=br(t,r,3),Zt(n,t,zt)},h.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=br(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},h.findLastKey=function(n,t,r){return t=br(t,r,3),Zt(n,t,Gt,true)},h.findWhere=function(n,t){return Zr(n,Ie(t))},h.first=Fr,h.has=function(n,t){return n?tu.call(n,t):false},h.identity=Oe,h.indexOf=Tr,h.isArguments=pe,h.isArray=Cu,h.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Ve.call(n)==et||false -},h.isDate=function(n){return n&&typeof n=="object"&&Ve.call(n)==ut||false},h.isElement=se,h.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?vu(u+r,0):yu(r||0,u-1))+1;else if(r)return u=Lr(n,t)-1,e&&n[u]===t?u:-1;for(;u--;)if(n[u]===t)return u;return-1},h.max=Jr,h.min=function(n,t,r){var e=1/0,o=e,i=typeof t;"number"!=i&&"string"!=i||!r||r[t]!==n||(t=null);var i=null==t,f=!(i&&Cu(n))&&me(n);if(i&&!f)for(r=-1,n=kr(n),i=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},h.template=function(n,t,r){var e=h.templateSettings;t=Su({},r||t,e,Tt),n=Be(null==n?"":n),r=Su({},t.imports,e.imports,Tt); -var u,o,i=Uu(r),f=be(r),a=0;r=t.interpolate||Y;var c="__p+='";if(r=$e((t.escape||Y).source+"|"+r.source+"|"+(r===M?z:Y).source+"|"+(t.evaluate||Y).source+"|$","g"),n.replace(r,function(t,r,e,i,f,l){return e||(e=i),c+=n.slice(a,l).replace(G,s),r&&(u=true,c+="'+__e("+r+")+'"),f&&(o=true,c+="';"+f+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t}),c+="';",(t=t.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(U,""):c).replace(W,"$1").replace(N,"$1;"),c="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}",t=xe(function(){return Ue(i,"return "+c).apply(m,f) -}),t.source=c,he(t))throw t;return t},h.trim=Ae,h.trimLeft=function(n,t){return(n=null==n?"":Be(n))?null==t?n.slice(g(n)):(t=Be(t),n.slice(o(n,t))):n},h.trimRight=function(n,t){return(n=null==n?"":Be(n))?null==t?n.slice(0,v(n)+1):(t=Be(t),n.slice(0,i(n,t)+1)):n},h.trunc=function(n,t){var r=30,e="...";if(ve(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Be(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Be(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e; -if(r=n.slice(0,o),null==u)return r+e;if(de(u)){if(n.slice(o).search(u)){var i,f,a=n.slice(0,o);for(u.global||(u=$e(u.source,(q.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(a);)f=i.index;r=r.slice(0,null==f?o:f)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Xt(h,function(n,t){var r="sample"!=t;h.prototype[t]||(h.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new V(o,u):o})}),h.VERSION=_,h.prototype.chain=function(){return this.__chain__=true,this},h.prototype.toJSON=Mr,h.prototype.toString=function(){return Be(this.__wrapped__) -},h.prototype.value=Mr,h.prototype.valueOf=Mr,H(["join","pop","shift"],function(n){var t=Me[n];h.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new V(r,n):r}}),H(["push","reverse","sort","unshift"],function(n){var t=Me[n];h.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),H(["concat","splice"],function(n){var t=Me[n];h.prototype[n]=function(){return new V(t.apply(this.__wrapped__,arguments),this.__chain__)}}),h}var m,_="3.0.0-pre",b=1,w=2,j=4,A=8,x=16,E=32,O=64,I="__lodash_"+_.replace(/[-.]/g,"_")+"__",R="Expected a function",k=Math.pow(2,32)-1,S=Math.pow(2,53)-1,C="__lodash_placeholder__",F=0,T=/^[A-Z]+$/,U=/\b__p\+='';/g,W=/\b(__p\+=)''\+/g,N=/(__e\(.*?\)|\b__t\))\+'';/g,L=/&(?:amp|lt|gt|quot|#39|#96);/g,$=/[&<>"'`]/g,B=/<%-([\s\S]+?)%>/g,D=/<%([\s\S]+?)%>/g,M=/<%=([\s\S]+?)%>/g,z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,q=/\w*$/,P=/^\s*function[ \n\r\t]+\w/,Z=/^0[xX]/,K=/^\[object .+?Constructor\]$/,V=/[\xC0-\xFF]/g,Y=/($^)/,J=/[.*+?^${}()|[\]\/\\]/g,X=/\bthis\b/,G=/['\n\r\u2028\u2029\\]/g,H=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,Q=" \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",nt="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 window WinRTError".split(" "),tt="[object Arguments]",rt="[object Array]",et="[object Boolean]",ut="[object Date]",ot="[object Error]",it="[object Number]",ft="[object Object]",at="[object RegExp]",ct="[object String]",lt="[object ArrayBuffer]",pt="[object Float32Array]",st="[object Float64Array]",ht="[object Int8Array]",gt="[object Int16Array]",vt="[object Int32Array]",yt="[object Uint8Array]",dt="[object Uint8ClampedArray]",mt="[object Uint16Array]",_t="[object Uint32Array]",bt={}; -bt[tt]=bt[rt]=bt[pt]=bt[st]=bt[ht]=bt[gt]=bt[vt]=bt[yt]=bt[dt]=bt[mt]=bt[_t]=true,bt[lt]=bt[et]=bt[ut]=bt[ot]=bt["[object Function]"]=bt["[object Map]"]=bt[it]=bt[ft]=bt[at]=bt["[object Set]"]=bt[ct]=bt["[object WeakMap]"]=false;var wt={};wt[tt]=wt[rt]=wt[lt]=wt[et]=wt[ut]=wt[pt]=wt[st]=wt[ht]=wt[gt]=wt[vt]=wt[it]=wt[ft]=wt[at]=wt[ct]=wt[yt]=wt[dt]=wt[mt]=wt[_t]=true,wt[ot]=wt["[object Function]"]=wt["[object Map]"]=wt["[object Set]"]=wt["[object WeakMap]"]=false;var jt={leading:false,maxWait:0,trailing:false},At={configurable:false,enumerable:false,value:null,writable:false},xt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Et={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ot={"\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","\xd7":" ","\xf7":" "},It={"function":true,object:true},Rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=It[typeof window]&&window||this,St=It[typeof exports]&&exports&&!exports.nodeType&&exports,It=It[typeof module]&&module&&!module.nodeType&&module,Ct=St&&It&&typeof global=="object"&&global; -!Ct||Ct.global!==Ct&&Ct.window!==Ct&&Ct.self!==Ct||(kt=Ct);var Ct=It&&It.exports===St&&St,Ft=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(kt._=Ft, define(function(){return Ft})):St&&It?Ct?(It.exports=Ft)._=Ft:St._=Ft:kt._=Ft}).call(this); \ No newline at end of file +;(function(){function n(n,t){for(var r=-1,e=t.length,u=Array(e);++rt||typeof n=="undefined")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 v(n){for(var t=-1,r=n.length;++ti(t,a)&&c.push(a);return c}function qt(n,t){var r=n?n.length:0;if(typeof r!="number"||-1>=r||r>T)return Gt(n,t); +for(var e=-1,u=Nr(n);++e=r||r>T)return Qt(n,t);for(var e=Nr(n);r--&&false!==t(e[r],r,e););return n}function Zt(n,t){var r=true;return qt(n,function(n,e,u){return r=!!t(n,e,u)}),r}function Kt(n,t){var r=[];return qt(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function Vt(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function Yt(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e>>1,a=r(n[f]),c=e?a<=t:ao(l,s)&&((t||a)&&l.push(s),c.push(p))}return c}function sr(n,t){for(var r=-1,e=t(n),u=e.length,o=Be(u);++rt)return r; +var e=typeof arguments[2];if("number"!=e&&"string"!=e||!arguments[3]||arguments[3][arguments[2]]!==arguments[1]||(t=2),3e?ju(u+e,0):e||0;else if(e)return e=qr(n,t),u&&n[e]===t?e:-1;return r(n,t,e)}function Mr(n){return zr(n,1) +}function zr(n,t,r){var u=-1,o=n?n.length:0;if(t=null==t?0:+t||0,0>t&&(t=-t>o?0:o+t),r=typeof r=="undefined"||r>o?o:+r||0,0>r&&(r+=o),r&&r==o&&!t)return e(n);for(o=t>r?0:r-t,r=Be(o);++ur?ju(e+r,0):r||0:0,typeof n=="string"||!Bu(n)&&Oe(n)?ru&&(u=f);else t=i&&f?o:xr(t,r,3),qt(n,function(n,r,o){r=t(n,r,o),(r>e||-1/0===r&&r===u)&&(e=r,u=n)});return u}function ee(n,t){return te(n,$e(t))}function ue(n,t,r,e){return(Bu(n)?St:fr)(n,xr(t,e,4),r,3>arguments.length,qt)}function oe(n,t,r,e){return(Bu(n)?Ct:fr)(n,xr(t,e,4),r,3>arguments.length,Pt) +}function ie(n){n=Nr(n);for(var t=-1,r=n.length,e=Be(r);++targuments.length)return Ar(n,w,null,t);var r=zr(arguments,2),e=Tr(r,ce.placeholder);return or(n,w|E,r,e,t)}function le(n,t){var r=w|j;if(2=r||r>t?(f&&iu(f),r=s,f=p=s=_,r&&(h=Vu(),a=n.apply(l,i),p||f||(i=l=null))):p=su(e,r)}function u(){p&&iu(p),f=p=s=_,(v||g!==t)&&(h=Vu(),a=n.apply(l,i),p||f||(i=l=null))}function o(){if(i=arguments,c=Vu(),l=this,s=v&&(p||!y),false===g)var r=y&&!p;else{f||y||(h=c);var o=g-(c-h),d=0>=o||o>g; +d?(f&&(f=iu(f)),h=c,a=n.apply(l,i)):f||(f=su(u,o))}return d&&p?p=iu(p):p||t===g||(p=su(e,t)),r&&(d=true,a=n.apply(l,i)),!d||p||f||(i=l=null),a}var i,f,a,c,l,p,s,h=0,g=false,v=true;if(!be(n))throw new Ye(C);if(t=0>t?0:t,true===r)var y=true,v=false;else we(r)&&(y=r.leading,g="maxWait"in r&&ju(+r.maxWait||0,t),v="trailing"in r?r.trailing:v);return o.cancel=function(){p&&iu(p),f&&iu(f),f=p=s=_},o}function ge(n){var t=zr(arguments,1),r=Tr(t,ge.placeholder);return or(n,E,t,r)}function ve(n){var t=zr(arguments,1),r=Tr(t,ve.placeholder); +return or(n,I,t,r)}function ye(n){return nr(n,Ee(n))}function de(n){return n&&typeof n=="object"&&typeof n.length=="number"&&tu.call(n)==ut||false}function me(n){return n&&typeof n=="object"&&1===n.nodeType&&-1>>0,e=n.constructor,u=-1,e=e&&n===e.prototype,o=r-1,i=Be(r),f=0t||null==n||!bu(t))return r;n=Ve(n);do t%2&&(r+=n),t=fu(t/2),n+=n;while(t);return r}function Se(n,t){return(n=null==n?"":Ve(n))?null==t?n.slice(v(n),y(n)+1):(t=Ve(t),n.slice(i(n,t),f(n,t)+1)):n}function Ce(n){try{return n()}catch(t){return _e(t)?t:Me(t)}}function Fe(n,t){return $t(n,t)}function Te(n){return n}function Ue(n){var t=zu(n),r=t.length; +if(1==r){var e=t[0],u=n[e];if(Sr(u))return function(n){return null!=n&&u===n[e]&&Qe.call(n,e)}}for(var o=r,i=Be(r),f=Be(r);o--;){var u=n[t[o]],a=Sr(u);i[o]=a,f[o]=a?u:Bt(u)}return function(n){if(o=r,null==n)return!o;for(;o--;)if(i[o]?f[o]!==n[t[o]]:!Qe.call(n,t[o]))return false;for(o=r;o--;)if(i[o]?!Qe.call(n,t[o]):!tr(f[o],n[t[o]],null,true))return false;return true}}function We(n,t,r){var e=true,u=we(t),o=null==r,i=o&&u&&zu(t),f=i&&nr(t,i);(i&&i.length&&!f.length||o&&!u)&&(o&&(r=t),f=false,t=n,n=this),f||(f=nr(t,zu(t))),false===r?e=false:we(r)&&"chain"in r&&(e=r.chain),r=-1,u=be(n); +for(o=f.length;++rk)return r}else n=0;return ar(r,e)}}(),Tu=yr(function(n,t,r){Qe.call(n,r)?++n[r]:n[r]=1}),Uu=yr(function(n,t,r){Qe.call(n,r)?n[r].push(t):n[r]=[t]}),Wu=yr(function(n,t,r){n[r]=t +}),Nu=yr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Lu=ge(ae,2),$u=dr(Lt),Bu=_u||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&tu.call(n)==ot||false};Su.dom||(me=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!Mu(n)||false});var Du=Ou||function(n){return typeof n=="number"&&bu(n)},Mu=au?function(n){if(!n||tu.call(n)!=lt)return false;var t=n.valueOf,r=je(t)&&(r=au(t))&&au(r);return r?n==r||au(n)==r:Ur(n)}:Ur,zu=wu?function(n){n=Lr(n);var t=n.constructor,r=n.length; +return t&&n===t.prototype||typeof r=="number"&&0--n?t.apply(this,arguments):void 0}},g.assign=$u,g.at=function(t){var r=t?t.length:0;return typeof r=="number"&&-1t?0:t)},g.dropRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),zr(n,0,0>t?0:t)},g.dropRightWhile=function(n,t,r){var e=n?n.length:0;for(t=xr(t,r,3);e--&&t(n[e],e,n););return zr(n,0,e+1)},g.dropWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=xr(t,r,3);++e(s?u(s,a):i(p,a))){for(t=e;--t;){var h=o[t];if(0>(h?u(h,a):i(n[t],a)))continue n}s&&s.push(a),p.push(a)}return p},g.invert=function(n,t){for(var r=-1,e=zu(n),u=e.length,o={};++rt?0:t)},g.takeRight=function(n,t,r){var e=n?n.length:0;return t=e-((null==t||r?1:t)||0),zr(n,0>t?0:t)},g.takeRightWhile=function(n,t,r){var e=n?n.length:0;for(t=xr(t,r,3);e--&&t(n[e],e,n););return zr(n,e+1)},g.takeWhile=function(n,t,r){var e=-1,u=n?n.length:0;for(t=xr(t,r,3);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},g.escape=function(n){return n=null==n?"":Ve(n),M.lastIndex=0,M.test(n)?n.replace(M,s):n},g.escapeRegExp=ke,g.every=Jr,g.find=Gr,g.findIndex=$r,g.findKey=function(n,t,r){return t=xr(t,r,3),Vt(n,t,Gt,true)},g.findLast=function(n,t,r){return t=xr(t,r,3),Vt(n,t,Pt)},g.findLastIndex=function(n,t,r){var e=n?n.length:0;for(t=xr(t,r,3);e--;)if(t(n[e],e,n))return e; +return-1},g.findLastKey=function(n,t,r){return t=xr(t,r,3),Vt(n,t,Qt,true)},g.findWhere=function(n,t){return Gr(n,Ue(t))},g.first=Br,g.has=function(n,t){return n?Qe.call(n,t):false},g.identity=Te,g.indexOf=Dr,g.isArguments=de,g.isArray=Bu,g.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&tu.call(n)==it||false},g.isDate=function(n){return n&&typeof n=="object"&&tu.call(n)==ft||false},g.isElement=me,g.isEmpty=function(n){if(null==n)return true;var t=n.length;return typeof t=="number"&&-1r?ju(u+r,0):Au(r||0,u-1))+1; +else if(r)return u=Pr(n,t)-1,e&&n[u]===t?u:-1;for(r=t===t;u--;)if(e=n[u],r?e===t:e!==e)return u;return-1},g.max=re,g.min=function(n,t,r){var e=1/0,u=e,i=typeof t;"number"!=i&&"string"!=i||!r||r[t]!==n||(t=null);var i=null==t,f=!(i&&Bu(n))&&Oe(n);if(i&&!f)for(r=-1,n=Nr(n),i=n.length;++rr?0:+r||0,n.length),n.lastIndexOf(t,r)==r},g.template=function(n,t,r){var e=g.templateSettings;t=$u({},r||t,e,Nt),n=Ve(null==n?"":n),r=$u({},t.imports,e.imports,Nt); +var u,o,i=zu(r),f=Ie(r),a=0;r=t.interpolate||X;var c="__p+='";if(r=Ke((t.escape||X).source+"|"+r.source+"|"+(r===P?Z:X).source+"|"+(t.evaluate||X).source+"|$","g"),n.replace(r,function(t,r,e,i,f,l){return e||(e=i),c+=n.slice(a,l).replace(nt,h),r&&(u=true,c+="'+__e("+r+")+'"),f&&(o=true,c+="';"+f+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=l+t.length,t}),c+="';",(t=t.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(L,""):c).replace($,"$1").replace(B,"$1;"),c="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}",t=Ce(function(){return ze(i,"return "+c).apply(_,f) +}),t.source=c,_e(t))throw t;return t},g.trim=Se,g.trimLeft=function(n,t){return(n=null==n?"":Ve(n))?null==t?n.slice(v(n)):(t=Ve(t),n.slice(i(n,t))):n},g.trimRight=function(n,t){return(n=null==n?"":Ve(n))?null==t?n.slice(0,y(n)+1):(t=Ve(t),n.slice(0,f(n,t)+1)):n},g.trunc=function(n,t){var r=30,e="...";if(we(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Ve(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Ve(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e; +if(r=n.slice(0,o),null==u)return r+e;if(xe(u)){if(n.slice(o).search(u)){var i,f,a=n.slice(0,o);for(u.global||(u=Ke(u.source,(K.exec(u)||"")+"g")),u.lastIndex=0;i=u.exec(a);)f=i.index;r=r.slice(0,null==f?o:f)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1t?0:+t||0,n.length),n)},Gt(g,function(n,t){var r="sample"!=t;g.prototype[t]||(g.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new J(o,u):o})}),g.VERSION=b,g.prototype.chain=function(){return this.__chain__=true,this},g.prototype.toJSON=Yr,g.prototype.toString=function(){return Ve(this.__wrapped__) +},g.prototype.value=Yr,g.prototype.valueOf=Yr,tt(["join","pop","shift"],function(n){var t=He[n];g.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);return n?new J(r,n):r}}),tt(["push","reverse","sort","unshift"],function(n){var t=He[n];g.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),tt(["concat","splice"],function(n){var t=He[n];g.prototype[n]=function(){return new J(t.apply(this.__wrapped__,arguments),this.__chain__)}}),g}var _,b="3.0.0-pre",w=1,j=2,A=4,x=8,O=16,E=32,I=64,k=150,R=16,S="__lodash_"+b.replace(/[-.]/g,"_")+"__",C="Expected a function",F=Math.pow(2,32)-1,T=Math.pow(2,53)-1,U="__lodash_placeholder__",W=0,N=/^[A-Z]+$/,L=/\b__p\+='';/g,$=/\b(__p\+=)''\+/g,B=/(__e\(.*?\)|\b__t\))\+'';/g,D=/&(?:amp|lt|gt|quot|#39|#96);/g,M=/[&<>"'`]/g,z=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,P=/<%=([\s\S]+?)%>/g,Z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,K=/\w*$/,V=/^\s*function[ \n\r\t]+\w/,Y=/^0[xX]/,H=/^\[object .+?Constructor\]$/,J=/[\xC0-\xFF]/g,X=/($^)/,G=/[.*+?^${}()|[\]\/\\]/g,Q=/\bthis\b/,nt=/['\n\r\u2028\u2029\\]/g,tt=/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g,rt=" \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",et="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(" "),ut="[object Arguments]",ot="[object Array]",it="[object Boolean]",ft="[object Date]",at="[object Error]",ct="[object Number]",lt="[object Object]",pt="[object RegExp]",st="[object String]",ht="[object ArrayBuffer]",gt="[object Float32Array]",vt="[object Float64Array]",yt="[object Int8Array]",dt="[object Int16Array]",mt="[object Int32Array]",_t="[object Uint8Array]",bt="[object Uint8ClampedArray]",wt="[object Uint16Array]",jt="[object Uint32Array]",At={}; +At[ut]=At[ot]=At[gt]=At[vt]=At[yt]=At[dt]=At[mt]=At[_t]=At[bt]=At[wt]=At[jt]=true,At[ht]=At[it]=At[ft]=At[at]=At["[object Function]"]=At["[object Map]"]=At[ct]=At[lt]=At[pt]=At["[object Set]"]=At[st]=At["[object WeakMap]"]=false;var xt={};xt[ut]=xt[ot]=xt[ht]=xt[it]=xt[ft]=xt[gt]=xt[vt]=xt[yt]=xt[dt]=xt[mt]=xt[ct]=xt[lt]=xt[pt]=xt[st]=xt[_t]=xt[bt]=xt[wt]=xt[jt]=true,xt[at]=xt["[object Function]"]=xt["[object Map]"]=xt["[object Set]"]=xt["[object WeakMap]"]=false;var Ot={leading:false,maxWait:0,trailing:false},Et={configurable:false,enumerable:false,value:null,writable:false},It={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},kt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Rt={"\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","\xd7":" ","\xf7":" "},St={"function":true,object:true},Ct={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ft=St[typeof window]&&window||this,Tt=St[typeof exports]&&exports&&!exports.nodeType&&exports,St=St[typeof module]&&module&&!module.nodeType&&module,Ut=Tt&&St&&typeof global=="object"&&global; +!Ut||Ut.global!==Ut&&Ut.window!==Ut&&Ut.self!==Ut||(Ft=Ut);var Ut=St&&St.exports===Tt&&Tt,Wt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Ft._=Wt, define(function(){return Wt})):Tt&&St?Ut?(St.exports=Wt)._=Wt:Tt._=Wt:Ft._=Wt}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 13ced1ca4..d1a822643 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -21,8 +21,7 @@ CURRY_FLAG = 4, CURRY_RIGHT_FLAG = 8, CURRY_BOUND_FLAG = 16, - PARTIAL_FLAG = 32, - PARTIAL_RIGHT_FLAG = 64; + PARTIAL_FLAG = 32; /** Used as the property name for wrapper metadata */ var EXPANDO = '__lodash_' + VERSION.replace(/[-.]/g, '_') + '__'; @@ -118,7 +117,7 @@ /** * Used to convert characters to HTML entities. * - * Note: Though the ">" character is escaped for symmetry, characters like + * **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' article](http://mathiasbynens.be/notes/ambiguous-ampersands) @@ -219,13 +218,33 @@ length = array ? array.length : 0; while (++index < length) { - if (array[index] === value) { + var other = array[index]; + if (other === value) { return index; } } return -1; } + /** + * The base implementation of `_.slice` without support for `start` and `end` + * arguments. + * + * @private + * @param {Array} array The array to slice. + * @returns {Array} Returns the slice of `array`. + */ + function baseSlice(array) { + var index = -1, + length = array ? array.length : 0, + result = Array(length); + + while (++index < length) { + result[index] = array[index]; + } + return result; + } + /** * Used by `_.sortBy` to compare transformed elements of `collection` and stable * sort them in ascending order. @@ -282,6 +301,9 @@ /** Used to resolve the decompiled source of functions */ var fnToString = Function.prototype.toString; + /** Used to check objects for own properties */ + var hasOwnProperty = objectProto.hasOwnProperty; + /** Used to restore the original `_` reference in `_.noConflict` */ var oldDash = root._; @@ -297,7 +319,6 @@ /** Native method references */ var ceil = Math.ceil, floor = Math.floor, - hasOwnProperty = objectProto.hasOwnProperty, push = arrayProto.push, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice; @@ -343,17 +364,17 @@ * * The non-chainable wrapper functions are: * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `contains`, - * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, isDate`, + * `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`, - * `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`, and `value` + * `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`, and `value` * * The wrapper function `sample` will return a wrapped value when `n` is * provided, otherwise it will return an unwrapped value. @@ -428,6 +449,18 @@ * @type boolean */ support.spliceObjects = (splice.call(object, 0, 1), !object[0]); + + /** + * Detect if the host objects are detectable (IE < 9). + * + * @memberOf _.support + * @type boolean + */ + try { + support.hostObject = !({ 'toString': 0 } + ''); + } catch(e) { + support.hostObject = false; + } }(0, 0)); /** @@ -482,15 +515,15 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEach(array, iterator) { + function arrayEach(array, iteratee) { var index = -1, length = array.length; while (++index < length) { - if (iterator(array[index], index, array) === breakIndicator) { + if (iteratee(array[index], index, array) === breakIndicator) { break; } } @@ -525,16 +558,16 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function arrayMap(array, iterator) { + function arrayMap(array, iteratee) { var index = -1, length = array.length, result = Array(length); while (++index < length) { - result[index] = iterator(array[index], index, array); + result[index] = iteratee(array[index], index, array); } return result; } @@ -551,12 +584,13 @@ function arrayFilter(array, predicate) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { - result.push(value); + result[++resIndex] = value; } } return result; @@ -568,13 +602,13 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iterator, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1, length = array.length; @@ -582,7 +616,7 @@ accumulator = array[++index]; } while (++index < length) { - accumulator = iterator(accumulator, array[index], index, array); + accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } @@ -593,20 +627,20 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iterator, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; if (initFromArray && length) { accumulator = array[--length]; } while (length--) { - accumulator = iterator(accumulator, array[length], length, array); + accumulator = iteratee(accumulator, array[length], length, array); } return accumulator; } @@ -648,7 +682,7 @@ while (++index < length) { var key = methodNames[index]; - object[key] = createWrapper([object[key], BIND_FLAG, null, object]); + object[key] = createWrapper(object[key], BIND_FLAG, null, object); } return object; } @@ -721,56 +755,6 @@ }()); } - /** - * The base implementation of `createWrapper` which creates the wrapper and - * sets its metadata. - * - * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new function. - */ - function baseCreateWrapper(data) { - var bitmask = data[1]; - if (bitmask == BIND_FLAG) { - return createBindWrapper(data); - } - var partialHolders = data[5]; - if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { - return createPartialWrapper(data); - } - var func = data[0], - arity = data[2], - thisArg = data[3], - partialArgs = data[4], - partialRightArgs = data[6]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isCurry = bitmask & CURRY_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG, - isCurryBound = bitmask & CURRY_BOUND_FLAG; - - var Ctor = !isBindKey && createCtorWrapper(func), - key = func; - - var wrapper = function() { - var length = arguments.length, - index = length, - args = Array(length); - - while (index--) { - args[index] = arguments[index]; - } - if (partialArgs) { - args = composeArgs(partialArgs, partialHolders, args); - } - var thisBinding = isBind ? thisArg : this; - return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); - }; - - return wrapper; - } - /** * The base implementation of `_.difference` which accepts a single array * of values to exclude. @@ -804,19 +788,19 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iterator) { + function baseEach(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwn(collection, iterator); + return baseForOwn(collection, iteratee); } var index = -1, iterable = toIterable(collection); while (++index < length) { - if (iterator(iterable[index], index, iterable) === breakIndicator) { + if (iteratee(iterable[index], index, iterable) === breakIndicator) { break; } } @@ -829,17 +813,17 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iterator) { + function baseEachRight(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwnRight(collection, iterator); + return baseForOwnRight(collection, iteratee); } var iterable = toIterable(collection); while (length--) { - if (iterator(iterable[length], length, iterable) === breakIndicator) { + if (iteratee(iterable[length], length, iterable) === breakIndicator) { break; } } @@ -953,24 +937,24 @@ /** * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` executing `iterator` for + * over `object` properties returned by `keysFunc` executing `iteratee` for * each property. Iterator functions may exit iteration early by explicitly * returning `false`. * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iterator, keysFunc) { + function baseFor(object, iteratee, keysFunc) { var index = -1, props = keysFunc(object), length = props.length; while (++index < length) { var key = props[index]; - if (iterator(object[key], key, object) === breakIndicator) { + if (iteratee(object[key], key, object) === breakIndicator) { break; } } @@ -983,17 +967,17 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iterator, keysFunc) { + function baseForRight(object, iteratee, keysFunc) { var props = keysFunc(object), length = props.length; while (length--) { var key = props[length]; - if (iterator(object[key], key, object) === breakIndicator) { + if (iteratee(object[key], key, object) === breakIndicator) { break; } } @@ -1006,11 +990,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForIn(object, iterator) { - return baseFor(object, iterator, keysIn); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); } /** @@ -1019,11 +1003,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwn(object, iterator) { - return baseFor(object, iterator, keys); + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } /** @@ -1032,32 +1016,32 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwnRight(object, iterator) { - return baseForRight(object, iterator, keys); + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); } /** - * The base implementation of `_.functions` which creates an array of function - * property names from those returned by `keysFunc`. + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from those provided. * * @private * @param {Object} object The object to inspect. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Array} Returns the new sorted array of property names. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the new array of filtered property names. */ - function baseFunctions(object, keysFunc) { + function baseFunctions(object, props) { var index = -1, - props = keysFunc(object), length = props.length, + resIndex = -1, result = []; while (++index < length) { var key = props[index]; if (isFunction(object[key])) { - result.push(key); + result[++resIndex] = key; } } return result; @@ -1215,14 +1199,14 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function baseMap(collection, iterator) { + function baseMap(collection, iteratee) { var result = []; baseEach(collection, function(value, key, collection) { - result.push(iterator(value, key, collection)); + result.push(iteratee(value, key, collection)); }); return result; } @@ -1241,51 +1225,13 @@ */ function basePartial(func, bitmask, args, holders, thisArg) { if (func) { - var data = func[EXPANDO], - arity = data ? data[2] : func.length; + var arity = func.length; arity -= args.length; } - var isPartial = bitmask & PARTIAL_FLAG, - newData = [func, bitmask, arity, thisArg, null, null]; - - newData[isPartial ? 4 : 6] = args; - newData[isPartial ? 5 : 7] = holders; - return createWrapper(newData); - } - - /** - * The base implementation of `_.pick` without support for `this` binding - * and individual property name arguments. - * - * @private - * @param {Object} object The source object. - * @param {Function|string[]} predicate The function called per iteration or - * property names to pick. - * @returns {Object} Returns the new object. - */ - function basePick(object, predicate) { - var result = {}; - - if (typeof predicate == 'function') { - baseForIn(object, function(value, key, object) { - if (predicate(value, key, object)) { - result[key] = value; - } - }); - return result; - } - var index = -1, - props = predicate, - length = props.length; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - return result; + return (bitmask & PARTIAL_FLAG) + ? createWrapper(func, bitmask, arity, thisArg, args, holders) + : createWrapper(func, bitmask, arity, thisArg, null, null, args, holders); } /** @@ -1308,18 +1254,18 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} accumulator The initial value. * @param {boolean} initFromCollection Specify using the first or last element * of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iterator, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { eachFunc(collection, function(value, index, collection) { accumulator = initFromCollection ? (initFromCollection = false, value) - : iterator(accumulator, value, index, collection) + : iteratee(accumulator, value, index, collection) }); return accumulator; } @@ -1351,24 +1297,24 @@ * @private * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {boolean} [retHighest=false] Specify returning the highest, instead * of the lowest, index at which a value should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ - function baseSortedIndex(array, value, iterator, retHighest) { + function baseSortedIndex(array, value, iteratee, retHighest) { var low = 0, high = array ? array.length : low; - value = iterator(value); + value = iteratee(value); var hintNum = typeof value == 'number' || (value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number'); while (low < high) { var mid = (low + high) >>> 1, - computed = iterator(array[mid]), - setLow = retHighest ? computed <= value : computed < value; + computed = iteratee(array[mid]), + setLow = retHighest ? (computed <= value) : (computed < value); if (hintNum && typeof computed != 'undefined') { computed = +computed; @@ -1389,22 +1335,22 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function baseUniq(array, iterator) { + function baseUniq(array, iteratee) { var index = -1, indexOf = getIndexOf(), length = array.length, result = [], - seen = iterator ? [] : result; + seen = iteratee ? [] : result; while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (indexOf(seen, computed) < 0) { - if (iterator) { + if (iteratee) { seen.push(computed); } result.push(value); @@ -1468,7 +1414,7 @@ /** * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection - * through `iterator`. The given setter function sets the keys and values of + * through `iteratee`. The given setter function sets the keys and values of * the accumulator object. If `initializer` is provided it is used to initialize * the accumulator object. * @@ -1478,9 +1424,9 @@ * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function(collection, iterator, thisArg) { + return function(collection, iteratee, thisArg) { var result = initializer ? initializer() : {}; - iterator = baseCallback(iterator, thisArg, 3); + iteratee = baseCallback(iteratee, thisArg, 3); if (isArray(collection)) { var index = -1, @@ -1488,11 +1434,11 @@ while (++index < length) { var value = collection[index]; - setter(result, value, iterator(value, index, collection), collection); + setter(result, value, iteratee(value, index, collection), collection); } } else { baseEach(collection, function(value, key, collection) { - setter(result, value, iterator(value, key, collection), collection); + setter(result, value, iteratee(value, key, collection), collection); }); } return result; @@ -1500,17 +1446,16 @@ } /** - * Creates a function that invokes the function specified in the metadata - * with its associated `this` binding. + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. - * @returns {Function} Returns the new bound function. + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. */ - function createBindWrapper(data) { - var func = data[0], - thisArg = data[3], - Ctor = createCtorWrapper(func); + function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); function wrapper() { return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments); @@ -1538,25 +1483,67 @@ } /** - * Creates a function that invokes the function specified in the metadata - * with its associated partially applied arguments and optional `this` binding. + * Creates a function that wraps `func` and invokes it with optional `this` + * binding of, partial application, and currying. * * @private - * @param {Array} data The metadata array. See `createWrapper` for more details. + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. + * @returns {Function} Returns the new function. + */ + function createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBind = bitmask & BIND_FLAG, + isBindKey = bitmask & BIND_KEY_FLAG, + isCurry = bitmask & CURRY_FLAG, + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + isCurryBound = bitmask & CURRY_BOUND_FLAG; + + var Ctor = !isBindKey && createCtorWrapper(func), + key = func; + + function wrapper() { + var length = arguments.length, + index = length, + args = Array(length); + + while (index--) { + args[index] = arguments[index]; + } + if (partialArgs) { + args = composeArgs(partialArgs, partialHolders, args); + } + var thisBinding = isBind ? thisArg : this; + return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); + } + return wrapper; + } + + /** + * Creates a function that wraps `func` and invokes it with the optional `this` + * binding of `thisArg` and the `partialArgs` 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 {Array} partialArgs An array of 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(data) { - var func = data[0], - thisArg = data[3], - partialArgs = data[4]; - - var isBind = data[1] & BIND_FLAG, + function createPartialWrapper(func, bitmask, partialArgs, thisArg) { + var isBind = bitmask & BIND_FLAG, Ctor = createCtorWrapper(func); function wrapper() { // avoid `arguments` object use disqualifying optimizations by // converting it to an array before passing it to `composeArgs` - var argsIndex = 0, + var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partialArgs.length, @@ -1566,7 +1553,7 @@ args[leftIndex] = partialArgs[leftIndex]; } while (argsLength--) { - args[leftIndex++] = arguments[argsIndex++]; + args[leftIndex++] = arguments[++argsIndex]; } return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args); } @@ -1578,9 +1565,8 @@ * `this` binding and partially applied arguments. * * @private - * @param {Array} data The metadata array. - * @param {Function|string} data[0] The function or method name to reference. - * @param {number} data[1] The bitmask of flags to compose. + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. * The bitmask may be composed of the following flags: * 1 - `_.bind` * 2 - `_.bindKey` @@ -1589,42 +1575,36 @@ * 16 - `_.curry` or `_.curryRight` of a bound function * 32 - `_.partial` * 64 - `_.partialRight` - * @param {number} data[2] The arity of `data[0]`. - * @param {*} [data[3]] The `this` binding of `data[0]`. - * @param {Array} [data[4]] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [data[5]] An array of `data[4]` placeholder indexes. - * @param {Array} [data[6]] An array of arguments to append to those - * provided to the new function. - * @param {Array} [data[7]] An array of `data[6]` placeholder indexes. + * @param {number} arity The arity of `func`. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partialArgs] An array of arguments to prepend to those provided to the new function. + * @param {Array} [partialHolders] An array of `partialArgs` placeholder indexes. + * @param {Array} [partialRightArgs] An array of arguments to append to those provided to the new function. + * @param {Array} [partialRightHolders] An array of `partialRightArgs` placeholder indexes. * @returns {Function} Returns the new function. */ - function createWrapper(data) { - var func = data[0], - bitmask = data[1]; - - var isBind = bitmask & BIND_FLAG, - isBindKey = bitmask & BIND_KEY_FLAG, - isPartial = bitmask & PARTIAL_FLAG, - isPartialRight = bitmask & PARTIAL_RIGHT_FLAG; - + function createWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders) { + var isBindKey = bitmask & BIND_KEY_FLAG; if (!isFunction(func)) { throw new TypeError(FUNC_ERROR_TEXT); } - var arity = data[2], - partialArgs = data[4], - partialRightArgs = data[6]; - + var isPartial = bitmask & PARTIAL_FLAG; if (isPartial && !partialArgs.length) { + bitmask &= ~PARTIAL_FLAG; isPartial = false; - data[1] = (bitmask &= ~PARTIAL_FLAG); - data[4] = data[5] = partialArgs = null; + partialArgs = partialHolders = null; } if (arity == null) { - arity = isBindKey ? 0 : func.length; + arity = func.length; } - data[2] = nativeMax(arity, 0); - return baseCreateWrapper(data); + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(func, thisArg); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !partialHolders.length) { + result = createPartialWrapper(func, bitmask, partialArgs, thisArg); + } else { + result = createHybridWrapper(func, bitmask, arity, thisArg, partialArgs, partialHolders, partialRightArgs, partialRightHolders); + } + return result; } /** @@ -1643,17 +1623,46 @@ } /** - * Checks if `value` is a native function. + * A specialized version of `_.pick` that picks `object` properties + * specified by the `props` array. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @param {Object} object The source object. + * @param {string[]} props The property names to pick. + * @returns {Object} Returns the new object. */ - function isNative(value) { - var type = typeof value; - return type == 'function' - ? reNative.test(fnToString.call(value)) - : (value && type == 'object' && reHostCtor.test(toString.call(value))) || false; + function pickByArray(object, props) { + var index = -1, + length = props.length, + result = {}; + + while (++index < length) { + var key = props[index]; + if (key in object) { + result[key] = object[key]; + } + } + return result; + } + + /** + * A specialized version of `_.pick` that picks `object` properties + * the predicate returns truthy for. + * + * @private + * @param {Object} object The source object. + * @param {Function} predicate The function called per iteration. + * @returns {Object} Returns the new object. + */ + function pickByCallback(object, predicate) { + var result = {}; + + baseForIn(object, function(value, key, object) { + if (predicate(value, key, object)) { + result[key] = value; + } + }); + return result; } /** @@ -1668,12 +1677,13 @@ function replaceHolders(array, placeholder) { var index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { if (array[index] === placeholder) { array[index] = PLACEHOLDER; - result.push(index); + result[++resIndex] = index; } } return result; @@ -1708,22 +1718,23 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function sortedUniq(array, iterator) { + function sortedUniq(array, iteratee) { var seen, index = -1, length = array.length, + resIndex = -1, result = []; while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (!index || seen !== computed) { seen = computed; - result.push(value); + result[++resIndex] = value; } } return result; @@ -1791,8 +1802,12 @@ } /** - * Creates an array excluding all values of the provided arrays using strict - * equality for comparisons, i.e. `===`. + * Creates an array excluding all values of the provided arrays using + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -1958,10 +1973,14 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` - * using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, + * 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. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @category Array @@ -2019,7 +2038,11 @@ /** * Creates an array of unique values present in all provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -2120,7 +2143,8 @@ index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1; } while (index--) { - if (array[index] === value) { + var other = array[index]; + if (other === value) { return index; } } @@ -2153,7 +2177,7 @@ /** * Slices `array` from the `start` index up to, but not including, the `end` index. * - * Note: This function is used instead of `Array#slice` to support node lists + * **Note:** This function is used instead of `Array#slice` to support node lists * in IE < 9 and to ensure dense arrays are returned. * * @static @@ -2176,6 +2200,9 @@ if (end < 0) { end += length; } + if (end && end == length && !start) { + return baseSlice(array); + } length = start > end ? 0 : (end - start); var result = Array(length); @@ -2188,14 +2215,14 @@ /** * Uses a binary search to determine the lowest index at which a value should * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iterator function is provided it is executed for `value` - * and each element of `array` to compute their sort ranking. The iterator + * of the array. If an iteratee function is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The iteratee * function is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -2204,10 +2231,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -2220,7 +2247,7 @@ * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; * - * // using an iterator function + * // using an iteratee function * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { * return this.data[word]; * }, dict); @@ -2230,9 +2257,9 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : baseCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator); + function sortedIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : baseCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee); } /** @@ -2264,7 +2291,11 @@ /** * Creates an array of unique values, in order, of the provided arrays using - * strict equality for comparisons, i.e. `===`. + * `SameValueZero` for equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -2281,30 +2312,34 @@ } /** - * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. Providing `true` for `isSorted` performs a - * faster search algorithm for sorted arrays. If an iterator function is - * provided it is executed for each value in the array to generate the criterion - * by which uniqueness is computed. The `iterator` is bound to `thisArg` and - * invoked with three arguments; (value, index, array). + * Creates a duplicate-value-free version of an array using `SameValueZero` + * for equality comparisons. Providing `true` for `isSorted` performs a faster + * search algorithm for sorted arrays. If an iteratee function is provided it + * is executed for each value in the array to generate the criterion by which + * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked + * with three arguments; (value, index, array). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * * @static * @memberOf _ * @alias unique * @category Array * @param {Array} array The array to inspect. * @param {boolean} [isSorted=false] Specify the array is sorted. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new duplicate-value-free array. * @example * @@ -2315,7 +2350,7 @@ * _.uniq([1, 1, 2], true); * // => [1, 2] * - * // using an iterator function + * // using an iteratee function * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); * // => [1, 2.5] * @@ -2323,7 +2358,7 @@ * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, iterator, thisArg) { + function uniq(array, isSorted, iteratee, thisArg) { var length = array ? array.length : 0; if (!length) { return []; @@ -2331,21 +2366,21 @@ // juggle arguments var type = typeof isSorted; if (type != 'boolean' && isSorted != null) { - thisArg = iterator; - iterator = isSorted; + thisArg = iteratee; + iteratee = isSorted; isSorted = false; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === array) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { + iteratee = null; } } - if (iterator != null) { - iterator = baseCallback(iterator, thisArg, 3); + if (iteratee != null) { + iteratee = baseCallback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() == baseIndexOf) - ? sortedUniq(array, iterator) - : baseUniq(array, iterator); + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); } /** @@ -2378,8 +2413,12 @@ } /** - * Creates an array excluding all provided values using strict equality for - * comparisons, i.e. `===`. + * Creates an array excluding all provided values using `SameValueZero` for + * equality comparisons. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -2392,8 +2431,8 @@ * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); * // => [2, 3, 4] */ - function without() { - return baseDifference(arguments[0], slice(arguments, 1)); + function without(array) { + return baseDifference(array, slice(arguments, 1)); } /** @@ -2412,7 +2451,13 @@ * // => [['fred', 30, true], ['barney', 40, false]] */ function zip() { - return unzip(arguments); + var length = arguments.length, + array = Array(length); + + while (length--) { + array[length] = arguments[length]; + } + return unzip(array); } /** @@ -2559,9 +2604,13 @@ /*--------------------------------------------------------------------------*/ /** - * Checks if `value` is present in `collection` using strict equality for - * comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the - * offset from the end of the collection. + * Checks if `value` is present in `collection` using `SameValueZero` for + * equality comparisons. If `fromIndex` is negative, it is used as the offset + * from the end of the collection. + * + * **Note:** `SameValueZero` is like strict equality, e.g. `===`, except that + * `NaN` matches `NaN`. See the [ES6 spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. * * @static * @memberOf _ @@ -2596,15 +2645,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding value - * of each key is the number of times the key was returned by `iterator`. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -2612,10 +2661,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -2674,10 +2723,10 @@ * // => false */ function every(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayEvery : baseEvery; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = baseCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arrayEvery : baseEvery; return func(collection, predicate); } @@ -2722,9 +2771,9 @@ * // => [{ 'name': 'barney', 'age': 36 }] */ function filter(collection, predicate, thisArg) { - predicate = baseCallback(predicate, thisArg, 3); - var func = isArray(collection) ? arrayFilter : baseFilter; + + predicate = baseCallback(predicate, thisArg, 3); return func(collection, predicate); } @@ -2809,12 +2858,12 @@ } /** - * Iterates over elements of `collection` executing `iterator` for each - * element. The `iterator` is bound to `thisArg` and invoked with three arguments; + * Iterates over elements of `collection` executing `iteratee` for each + * element. The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * - * Note: As with other "Collections" methods, objects with a `length` property + * **Note:** As with other "Collections" methods, objects with a `length` property * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` * may be used for object iteration. * @@ -2823,8 +2872,8 @@ * @alias each * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * @@ -2832,25 +2881,25 @@ * // => logs each value and returns the array * * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); - * // => logs each value-key pair and returns the object (property order is not guaranteed across environments) + * // => logs each value-key pair and returns the object (property order is not guaranteed) */ - function forEach(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iterator) - : baseEach(collection, baseCallback(iterator, thisArg, 3)); + function forEach(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEach(collection, iteratee) + : baseEach(collection, baseCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding + * each element of `collection` through `iteratee`. The corresponding * value of each key is an array of the elements responsible for generating - * the key. The `iterator` is bound to `thisArg` and invoked with three + * the key. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -2858,10 +2907,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -2885,15 +2934,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iterator`. The corresponding value + * each element of the collection through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -2901,10 +2950,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -2954,13 +3003,13 @@ /** * Creates an array of values by running each element in the collection through - * `iterator`. The `iterator` is bound to `thisArg` and invoked with three + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -2969,10 +3018,10 @@ * @alias collect * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new mapped array. * @example * @@ -2980,7 +3029,7 @@ * // => [3, 6, 9] * * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); - * // => [3, 6, 9] (property order is not guaranteed across environments) + * // => [3, 6, 9] (property order is not guaranteed) * * var characters = [ * { 'name': 'barney', 'age': 36 }, @@ -2991,24 +3040,24 @@ * _.map(characters, 'name'); * // => ['barney', 'fred'] */ - function map(collection, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); + function map(collection, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, iterator); + return func(collection, iteratee); } /** * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iterator function is provided it + * or falsey `-Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -3016,10 +3065,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the maximum value. * @example * @@ -3041,17 +3090,17 @@ * _.max(characters, 'age'); * // => { 'name': 'fred', 'age': 40 }; */ - function max(collection, iterator, thisArg) { + function max(collection, iteratee, thisArg) { var computed = -Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - if (iterator == null) { + if (iteratee == null) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -3063,10 +3112,10 @@ } } } else { - iterator = baseCallback(iterator, thisArg, 3); + iteratee = baseCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current > computed || (current === -Infinity && current === result)) { computed = current; result = value; @@ -3078,15 +3127,15 @@ /** * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iterator function is provided it + * or falsey `Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * 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 `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -3094,10 +3143,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the minimum value. * @example * @@ -3119,17 +3168,17 @@ * _.min(characters, 'age'); * // => { 'name': 'barney', 'age': 36 }; */ - function min(collection, iterator, thisArg) { + function min(collection, iteratee, thisArg) { var computed = Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - if (iterator == null) { + if (iteratee == null) { var index = -1, iterable = toIterable(collection), length = iterable.length; @@ -3141,10 +3190,10 @@ } } } else { - iterator = baseCallback(iterator, thisArg, 3); + iteratee = baseCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current < computed || (current === Infinity && current === result)) { computed = current; result = value; @@ -3227,10 +3276,10 @@ /** * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iterator`, where each successive + * each element in the collection through `iteratee`, where each successive * execution consumes the return value of the previous execution. If `accumulator` * is not provided the first element of the collection is used as the initial - * value. The `iterator` is bound to `thisArg`and invoked with four arguments; + * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * * @static @@ -3238,9 +3287,9 @@ * @alias foldl, inject * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -3251,11 +3300,11 @@ * result[key] = n * 3; * return result; * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * // => { 'a': 3, 'b': 6, 'c': 9 } (property order is not guaranteed) */ - function reduce(collection, iterator, accumulator, thisArg) { + function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, baseCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach); + return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); } /** @@ -3267,9 +3316,9 @@ * @alias foldr * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -3277,9 +3326,9 @@ * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iterator, accumulator, thisArg) { + function reduceRight(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, baseCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); + return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); } /** @@ -3321,8 +3370,12 @@ * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] */ function reject(collection, predicate, thisArg) { + var func = isArray(collection) ? arrayFilter : baseFilter; + predicate = baseCallback(predicate, thisArg, 3); - return filter(collection, negate(predicate)); + return func(collection, function(value, index, collection) { + return !predicate(value, index, collection); + }); } /** @@ -3456,27 +3509,27 @@ * // => false */ function some(collection, predicate, thisArg) { + var func = isArray(collection) ? arraySome : baseSome; if (typeof predicate != 'function' || typeof thisArg != 'undefined') { predicate = baseCallback(predicate, thisArg, 3); } - var func = isArray(collection) ? arraySome : baseSome; return func(collection, predicate); } /** * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iterator`. This method performs + * running each element in a collection through `iteratee`. This method performs * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * 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 `iterator` the collection + * If an array of property names is provided for `iteratee` the collection * is sorted by each property value. * - * If an object is provided for `iterator` the created "_.where" style callback + * 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`. * @@ -3484,10 +3537,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [iterator=identity] The function + * @param {Array|Function|Object|string} [iteratee=identity] The function * called per iteration. If property name(s) or an object is provided it * is used to create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example * @@ -3512,15 +3565,15 @@ * _.map(_.sortBy(characters, ['name', 'age']), _.values); * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortBy(collection, iterator, thisArg) { + function sortBy(collection, iteratee, thisArg) { var index = -1, length = collection && collection.length, result = Array(length < 0 ? 0 : length >>> 0); - iterator = baseCallback(iterator, thisArg, 3); + iteratee = baseCallback(iteratee, thisArg, 3); baseEach(collection, function(value, key, collection) { result[++index] = { - 'criteria': iterator(value, key, collection), + 'criteria': iteratee(value, key, collection), 'index': index, 'value': value }; @@ -3550,7 +3603,7 @@ function toArray(collection) { var length = collection ? collection.length : 0; if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { - return slice(collection); + return baseSlice(collection); } return values(collection); } @@ -3658,7 +3711,7 @@ * and prepends any additional `bind` arguments to those provided to the bound * function. * - * Note: Unlike native `Function#bind` this method does not set the `length` + * **Note:** Unlike native `Function#bind` this method does not set the `length` * property of bound functions. * * @static @@ -3680,7 +3733,7 @@ */ function bind(func, thisArg) { return arguments.length < 3 - ? createWrapper([func, BIND_FLAG, null, thisArg]) + ? createWrapper(func, BIND_FLAG, null, thisArg) : basePartial(func, BIND_FLAG | PARTIAL_FLAG, slice(arguments, 2), [], thisArg); } @@ -3690,7 +3743,7 @@ * of method names. If no method names are provided all enumerable function * properties, own and inherited, of `object` are bound. * - * Note: This method does not set the `length` property of bound functions. + * **Note:** This method does not set the `length` property of bound functions. * * @static * @memberOf _ @@ -3780,7 +3833,7 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the * debounced function return the result of the last `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * @@ -4046,34 +4099,6 @@ }; } - /** - * Creates a function that negates the result of the predicate `func`. The - * `func` function is executed with the `this` binding and arguments of the - * created function. - * - * @static - * @memberOf _ - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new function. - * @example - * - * function isEven(n) { - * return n % 2 == 0; - * } - * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] - */ - function negate(predicate) { - if (!isFunction(predicate)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - return !predicate.apply(this, arguments); - }; - } - /** * Creates a function that is restricted to execute `func` once. Repeat calls * to the function return the value of the first call. The `func` is executed @@ -4099,7 +4124,7 @@ * prepended to those provided to the new function. This method is similar to * `_.bind` except it does **not** alter the `this` binding. * - * Note: This method does not set the `length` property of partially applied + * **Note:** This method does not set the `length` property of partially applied * functions. * * @static @@ -4117,9 +4142,9 @@ */ function partial(func) { var args = slice(arguments, 1), - partialHolders = replaceHolders(args, partial.placeholder); + holders = replaceHolders(args, partial.placeholder); - return basePartial(func, PARTIAL_FLAG, args, partialHolders); + return basePartial(func, PARTIAL_FLAG, args, holders); } /** @@ -4130,7 +4155,7 @@ * Subsequent calls to the throttled function return the result of the last * `func` call. * - * Note: If `leading` and `trailing` options are `true`, `func` is called on + * **Note:** If `leading` and `trailing` options are `true`, `func` is called on * the trailing edge of the timeout only if the the throttled function is * invoked more than once during the `wait` timeout. * @@ -4263,7 +4288,7 @@ * cloning is handled by the method instead. The `customizer` is bound to * `thisArg` and invoked with two argument; (value, index|key). * - * Note: This method is loosely based on the structured clone algorithm. Functions + * **Note:** This method is loosely based on the structured clone algorithm. Functions * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and * objects created by constructors other than `Object` are cloned to plain `Object` objects. * See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) @@ -4304,7 +4329,7 @@ */ function clone(value) { return isObject(value) - ? (isArray(value) ? slice(value) : assign({}, value)) + ? (isArray(value) ? baseSlice(value) : assign({}, value)) : value; } @@ -4313,7 +4338,7 @@ * object for all destination properties that resolve to `undefined`. Once a * property is set, additional defaults of the same property are ignored. * - * Note: See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) + * **Note:** See the [documentation example of `_.partialRight`](http://lodash.com/docs#partialRight) * for a deep version of this method. * * @static @@ -4359,14 +4384,14 @@ * @alias methods * @category Object * @param {Object} object The object to inspect. - * @returns {Array} Returns the new sorted array of property names. + * @returns {Array} Returns the new array of property names. * @example * * _.functions(_); * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] */ function functions(object) { - return baseFunctions(object, keysIn); + return baseFunctions(object, keysIn(object)); } /** @@ -4583,7 +4608,7 @@ * instead. The `customizer` is bound to `thisArg` and invoked with three * arguments; (value, other, key). * - * Note: This method supports comparing arrays, booleans, `Date` objects, + * **Note:** This method supports comparing arrays, booleans, `Date` objects, * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes * are **not** supported. Provide a customizer function to extend support * for comparing other values. @@ -4643,7 +4668,7 @@ /** * Checks if `value` is a finite primitive number. * - * Note: This method is based on ES6 `Number.isFinite`. See the + * **Note:** This method is based on ES6 `Number.isFinite`. See the * [ES6 spec](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) * for more details. * @@ -4706,7 +4731,7 @@ * Checks if `value` is the language type of `Object`. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * - * Note: See the [ES5 spec](http://es5.github.io/#x8) for more details. + * **Note:** See the [ES5 spec](http://es5.github.io/#x8) for more details. * * @static * @memberOf _ @@ -4734,7 +4759,7 @@ /** * Checks if `value` is `NaN`. * - * Note: This method is not the same as native `isNaN` which returns `true` + * **Note:** This method is not the same as native `isNaN` which returns `true` * for `undefined` and other non-numeric values. See the [ES5 spec](http://es5.github.io/#x15.1.2.4) * for more details. * @@ -4763,6 +4788,27 @@ return isNumber(value) && value != +value; } + /** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Object + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + */ + function isNative(value) { + if (isFunction(value)) { + return reNative.test(fnToString.call(value)); + } + if (value && typeof value == 'object') { + return !('constructor' in value) && isHostObject(value) + ? reNative.test(value) + : reHostCtor.test(toString.call(value)); + } + return false; + } + /** * Checks if `value` is `null`. * @@ -4786,7 +4832,7 @@ /** * Checks if `value` is classified as a `Number` primitive or object. * - * Note: To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified + * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified * as numbers, use the `_.isFinite` method. * * @static @@ -4890,7 +4936,7 @@ * Shape.prototype.z = 0; * * _.keys(new Shape); - * // => ['x', 'y'] (property order is not guaranteed across environments) + * // => ['x', 'y'] (property order is not guaranteed) */ var keys = !nativeKeys ? shimKeys : function(object) { return isObject(object) ? nativeKeys(object) : []; @@ -4914,7 +4960,7 @@ * Shape.prototype.z = 0; * * _.keysIn(new Shape); - * // => ['x', 'y', 'z'] (property order is not guaranteed across environments) + * // => ['x', 'y', 'z'] (property order is not guaranteed) */ function keysIn(object) { var result = []; @@ -4958,8 +5004,10 @@ if (object == null) { return {}; } - var omitProps = baseFlatten(arguments, false, false, 1); - return basePick(toObject(object), baseDifference(keysIn(object), arrayMap(omitProps, String))); + var iterable = toObject(object), + props = arrayMap(baseFlatten(arguments, false, false, 1), String); + + return pickByArray(iterable, baseDifference(keysIn(iterable), props)); } /** @@ -4974,7 +5022,7 @@ * @example * * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) + * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed) */ function pairs(object) { var index = -1, @@ -5019,7 +5067,7 @@ function pick(object) { return object == null ? {} - : basePick(toObject(object), baseFlatten(arguments, false, false, 1)); + : pickByArray(toObject(object), baseFlatten(arguments, false, false, 1)); } /** @@ -5040,7 +5088,7 @@ * Shape.prototype.z = 0; * * _.values(new Shape(2, 1)); - * // => [2, 1] (property order is not guaranteed across environments) + * // => [2, 1] (property order is not guaranteed) */ function values(object) { return baseValues(object, keys); @@ -5052,7 +5100,7 @@ * Converts the characters "&", "<", ">", '"', and "'" in `string` to * their corresponding HTML entities. * - * Note: No other characters are escaped. To escape additional characters + * **Note:** No other characters are escaped. To escape additional characters * use a third-party library like [_he_](http://mths.be/he). * * When working with HTML you should always quote attribute values to reduce @@ -5105,7 +5153,7 @@ * properties may be accessed as free variables in the template. If a setting * object is provided it overrides `_.templateSettings` for the template. * - * Note: In the development build `_.template` utilizes sourceURLs for easier debugging. + * **Note:** In the development build `_.template` utilizes sourceURLs for easier debugging. * See the [HTML5 Rocks article on sourcemaps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) * for more details. * @@ -5252,7 +5300,7 @@ * `&`, `<`, `>`, `"`, and `'` in `string` to their * corresponding characters. * - * Note: No other HTML entities are unescaped. To unescape additional HTML + * **Note:** No other HTML entities are unescaped. To unescape additional HTML * entities use a third-party library like [_he_](http://mths.be/he). * * @static @@ -5652,16 +5700,16 @@ } /** - * Executes the iterator function `n` times, returning an array of the results - * of each execution. The `iterator` is bound to `thisArg` and invoked with + * Executes the iteratee function `n` times, returning an array of the results + * of each execution. The `iteratee` is bound to `thisArg` and invoked with * one argument; (index). * * @static * @memberOf _ * @category Utility - * @param {number} n The number of times to execute `iterator`. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {number} n The number of times to execute `iteratee`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the array of results. * @example * @@ -5674,18 +5722,18 @@ * _.times(3, function(n) { this.cast(n); }, mage); * // => also calls `mage.castSpell(n)` three times */ - function times(n, iterator, thisArg) { + function times(n, iteratee, thisArg) { n = nativeIsFinite(n = +n) && n > -1 ? n : 0; - iterator = baseCallback(iterator, thisArg, 1); + iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { - result[index] = iterator(index); + result[index] = iteratee(index); } else { - iterator(index); + iteratee(index); } } return result; diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index e3771cecf..f0c9b9e3d 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,44 +3,43 @@ * Lo-Dash 3.0.0-pre (Custom Build) lodash.com/license | Underscore.js 1.6.0 underscorejs.org/LICENSE * Build: `lodash underscore -o ./dist/lodash.underscore.js` */ -;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined"){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function b(n,r){var t=n?n.length:0; -if(typeof t!="number"||-1>=t||t>Rr)return x(n,r,Wt);for(var e=-1,u=P(n);++e=t||t>Rr){for(var t=Wt(n),e=t.length;e--;){var u=t[e];if(r(n[u],u,n)===Br)break}return n}for(e=P(n);t--&&r(e[t],t,e)!==Br;);return n}function d(n,r){var t=true;return b(n,function(n,e,u){return(t=!!r(n,e,u))||Br}),t}function j(n,r){var t=[];return b(n,function(n,e,u){r(n,e,u)&&t.push(n)}),t}function w(n,r,t){var e;return t(n,function(n,t,u){return r(n,t,u)?(e=n,Br):void 0 -}),e}function A(n,r,t,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ee(i,a)&&(r&&i.push(a),o.push(f))}return o}function $(n,r){return function(t,e,u){var o=r?r():{};if(e=g(e,u,3),Ut(t)){u=-1;for(var i=t.length;++ur?0:r)}function G(r,t,e){var u=r?r.length:0;if(typeof e=="number")e=0>e?Et(u+e,0):e||0;else if(e)return e=K(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function H(n,r,t){return J(n,null==r||t?1:0>r?0:r)}function J(n,r,t){var e=-1,u=n?n.length:0; -for(r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),t=typeof t=="undefined"||t>u?u:+t||0,0>t&&(t+=u),u=r>t?0:t-r,t=Array(u);++e>>1,f=t(n[i]),a=fu&&(u=i)}else r=g(r,t,3),b(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function er(n,r){return rr(n,kr(r))}function ur(n,r,t,e){return(Ut(n)?p:M)(n,g(r,e,4),t,3>arguments.length,b) -}function or(n,r,t,e){return(Ut(n)?s:M)(n,g(r,e,4),t,3>arguments.length,_)}function ir(n){n=P(n);for(var r=-1,t=n.length,e=Array(t);++rarguments.length?W([n,Ir,null,r]):S(n,Ir|Mr,J(arguments,2),[],r)}function cr(n,r,t){function e(){var t=r-(Dt()-c);0>=t||t>r?(f&&clearTimeout(f),t=s,f=p=s=Sr,t&&(h=Dt(),a=n.apply(l,i),p||f||(i=l=null))):p=setTimeout(e,t) -}function u(){p&&clearTimeout(p),f=p=s=Sr,(v||g!==r)&&(h=Dt(),a=n.apply(l,i),p||f||(i=l=null))}function o(){if(i=arguments,c=Dt(),l=this,s=v&&(p||!y),false===g)var t=y&&!p;else{f||y||(h=c);var o=g-(c-h),m=0>=o||o>g;m?(f&&(f=clearTimeout(f)),h=c,a=n.apply(l,i)):f||(f=setTimeout(u,o))}return m&&p?p=clearTimeout(p):p||r===g||(p=setTimeout(e,r)),t&&(m=true,a=n.apply(l,i)),!m||p||f||(i=l=null),a}var i,f,a,c,l,p,s,h=0,g=false,v=true;if(!mr(n))throw new TypeError($r);if(r=0>r?0:r,true===t)var y=true,v=false;else br(t)&&(y=t.leading,g="maxWait"in t&&Et(+t.maxWait||0,r),v="trailing"in t?t.trailing:v); -return o.cancel=function(){p&&clearTimeout(p),f&&clearTimeout(f),f=p=s=Sr},o}function lr(n){if(!mr(n))throw new TypeError($r);return function(){return!n.apply(this,arguments)}}function pr(n){for(var r=J(arguments,1),t=r,e=pr.placeholder,u=-1,o=t.length,i=[];++u"'`]/g,Cr=/^\[object .+?Constructor\]$/,Pr=/($^)/,Vr=/[.*+?^${}()|[\]\/\\]/g,Gr=/['\n\r\u2028\u2029\\]/g,Hr="[object Arguments]",Jr="[object Boolean]",Kr="[object Date]",Lr="[object Error]",Qr="[object Number]",Xr="[object Object]",Yr="[object RegExp]",Zr="[object String]",nt={}; -nt[Hr]=nt["[object Array]"]=nt["[object Float32Array]"]=nt["[object Float64Array]"]=nt["[object Int8Array]"]=nt["[object Int16Array]"]=nt["[object Int32Array]"]=nt["[object Uint8Array]"]=nt["[object Uint8ClampedArray]"]=nt["[object Uint16Array]"]=nt["[object Uint32Array]"]=true,nt["[object ArrayBuffer]"]=nt[Jr]=nt[Kr]=nt[Lr]=nt["[object Function]"]=nt["[object Map]"]=nt[Qr]=nt[Xr]=nt[Yr]=nt["[object Set]"]=nt[Zr]=nt["[object WeakMap]"]=false;var rt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},tt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},et={"function":true,object:true},ut={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ot=et[typeof window]&&window||this,it=et[typeof exports]&&exports&&!exports.nodeType&&exports,ft=et[typeof module]&&module&&!module.nodeType&&module,at=it&&ft&&typeof global=="object"&&global; -!at||at.global!==at&&at.window!==at&&at.self!==at||(ot=at);var ct=ft&&ft.exports===it&&it,lt=Array.prototype,pt=Object.prototype,st=Function.prototype.toString,ht=ot._,gt=pt.toString,vt=RegExp("^"+function(n){return n=null==n?"":n+"",Vr.lastIndex=0,Vr.test(n)?n.replace(Vr,"\\$&"):n}(gt).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=Math.ceil,mt=Math.floor,bt=pt.hasOwnProperty,_t=lt.push,dt=pt.propertyIsEnumerable,jt=lt.splice,wt=z(wt=Object.create)&&wt,At=z(At=Array.isArray)&&At,xt=ot.isFinite,Tt=z(Tt=Object.keys)&&Tt,Et=Math.max,Ot=Math.min,kt=z(kt=Date.now)&&kt,St=Math.random,It={}; -!function(){var n={0:1,length:1};It.spliceObjects=(jt.call(n,0,1),!n[0])}(0,0),o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},wt||(v=function(){function n(){}return function(r){if(br(r)){n.prototype=r;var t=new n;n.prototype=null}return t||ot.Object()}}());var Ft=H,Mt=V,qt=$(function(n,r,t){bt.call(n,t)?++n[t]:n[t]=1}),Bt=$(function(n,r,t){bt.call(n,t)?n[t].push(r):n[t]=[r]}),$t=$(function(n,r,t){n[t]=r}),Nt=$(function(n,r,t){n[t?0:1].push(r) -},function(){return[[],[]]}),Rt=pr(function(n,r){var t;if(!mr(r))throw new TypeError($r);return function(){return 0<--n?t=r.apply(this,arguments):r=null,t}},2);vr(arguments)||(vr=function(n){var r=n&&typeof n=="object"?n.length:Sr;return typeof r=="number"&&-1--n?r.apply(this,arguments):void 0}},o.bind=ar,o.bindAll=function(n){for(var r=n,t=1r?0:r) -},o.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},o.invert=function(n){for(var r=-1,t=Wt(n),e=t.length,u={};++ro?0:o>>>0);for(t=g(t,e,3),b(n,function(n,r,e){i[++u]={a:t(n,r,e),b:u,c:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].c;return i},o.take=Mt,o.tap=function(n,r){return r(n),n},o.throttle=function(n,r,t){var e=true,u=true;if(!mr(n))throw new TypeError(funcErrorText);return false===t?e=false:br(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),cr(n,r,{leading:e,maxWait:r,trailing:u}) -},o.times=function(n,r,t){n=xt(n=+n)&&-1r?0:r))},o.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?Et(e+t,0):Ot(t||0,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.max=tr,o.min=function(n,r,t){var e=1/0,u=e,o=typeof r; -if("number"!=o&&"string"!=o||!t||t[r]!==n||(r=null),null==r)for(t=-1,n=P(n),o=n.length;++tr?0:+r||0,n.length),n)},Or(sr({},o)),o.VERSION="3.0.0-pre",o.prototype.chain=function(){return this.__chain__=true,this},o.prototype.value=function(){return this.__wrapped__ -},f("pop push reverse shift sort splice unshift".split(" "),function(n){var r=lt[n];o.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),It.spliceObjects||0!==n.length||delete n[0],this}}),f(["concat","join","slice"],function(n){var r=lt[n];o.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ot._=o, define("underscore",function(){return o -})):it&&ft?ct?(ft.exports=o)._=o:it._=o:ot._=o}).call(this); \ No newline at end of file +;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined"){t=1;break n}if(tu(r,i)&&o.push(i)}return o}function b(n,r){var t=n?n.length:0;if(typeof t!="number"||-1>=t||t>Br){for(var t=-1,e=Nt(n),u=e.length;++t=t||t>Br){for(var t=Nt(n),e=t.length;e--;){var u=t[e];if(r(n[u],u,n)===Fr)break}return n}for(e=z(n);t--&&r(e[t],t,e)!==Fr;);return n +}function d(n,r){var t=true;return b(n,function(n,e,u){return(t=!!r(n,e,u))||Fr}),t}function j(n,r){var t=[];return b(n,function(n,e,u){r(n,e,u)&&t.push(n)}),t}function w(n,r,t){var e;return t(n,function(n,t,u){return r(n,t,u)?(e=n,Fr):void 0}),e}function A(n,r,t,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++ee(i,f)&&(r&&i.push(f),o.push(a))}return o}function M(n,r){return function(t,e,u){var o=r?r():{};if(e=v(e,u,3),$t(t)){u=-1;for(var i=t.length;++ur?0:r)}function H(r,t,e){var u=r?r.length:0;if(typeof e=="number")e=0>e?At(u+e,0):e||0;else if(e)return e=G(r,t),u&&r[e]===t?e:-1; +return n(r,t,e)}function P(n,r,t){return V(n,null==r||t?1:0>r?0:r)}function V(n,t,e){var u=-1,o=n?n.length:0;if(t=null==t?0:+t||0,0>t&&(t=-t>o?0:o+t),e=typeof e=="undefined"||e>o?o:+e||0,0>e&&(e+=o),e&&e==o&&!t)return r(n);for(o=t>e?0:e-t,e=Array(o);++u>>1,a=t(n[i]),f=au&&(u=i)}else r=v(r,t,3),b(n,function(n,t,o){t=r(n,t,o),(t>e||-1/0===t&&t===u)&&(e=t,u=n)});return u}function rr(n,r){return Z(n,Er(r))}function tr(n,r,t,e){return($t(n)?s:S)(n,v(r,e,4),t,3>arguments.length,b)}function er(n,r,t,e){return($t(n)?g:S)(n,v(r,e,4),t,3>arguments.length,_)}function ur(n){n=z(n);for(var r=-1,t=n.length,e=Array(t);++rarguments.length?R(n,kr,r):O(n,kr|Ir,V(arguments,2),[],r)}function ar(n,r,t){function e(){var t=r-(Rt()-c);0>=t||t>r?(a&&clearTimeout(a),t=s,a=p=s=Or,t&&(g=Rt(),f=n.apply(l,i),p||a||(i=l=null))):p=setTimeout(e,t)}function u(){p&&clearTimeout(p),a=p=s=Or,(v||h!==r)&&(g=Rt(),f=n.apply(l,i),p||a||(i=l=null))}function o(){if(i=arguments,c=Rt(),l=this,s=v&&(p||!y),false===h)var t=y&&!p;else{a||y||(g=c);var o=h-(c-g),m=0>=o||o>h;m?(a&&(a=clearTimeout(a)),g=c,f=n.apply(l,i)):a||(a=setTimeout(u,o)) +}return m&&p?p=clearTimeout(p):p||r===h||(p=setTimeout(e,r)),t&&(m=true,f=n.apply(l,i)),!m||p||a||(i=l=null),f}var i,a,f,c,l,p,s,g=0,h=false,v=true;if(!hr(n))throw new TypeError(Mr);if(r=0>r?0:r,true===t)var y=true,v=false;else vr(t)&&(y=t.leading,h="maxWait"in t&&At(+t.maxWait||0,r),v="trailing"in t?t.trailing:v);return o.cancel=function(){p&&clearTimeout(p),a&&clearTimeout(a),a=p=s=Or},o}function fr(n){for(var r=V(arguments,1),t=r,e=fr.placeholder,u=-1,o=t.length,i=-1,a=[];++u"'`]/g,Wr=/^\[object .+?Constructor\]$/,Dr=/($^)/,zr=/[.*+?^${}()|[\]\/\\]/g,Cr=/['\n\r\u2028\u2029\\]/g,Hr="[object Arguments]",Pr="[object Boolean]",Vr="[object Date]",Gr="[object Error]",Jr="[object Number]",Kr="[object Object]",Lr="[object RegExp]",Qr="[object String]",Xr={}; +Xr[Hr]=Xr["[object Array]"]=Xr["[object Float32Array]"]=Xr["[object Float64Array]"]=Xr["[object Int8Array]"]=Xr["[object Int16Array]"]=Xr["[object Int32Array]"]=Xr["[object Uint8Array]"]=Xr["[object Uint8ClampedArray]"]=Xr["[object Uint16Array]"]=Xr["[object Uint32Array]"]=true,Xr["[object ArrayBuffer]"]=Xr[Pr]=Xr[Vr]=Xr[Gr]=Xr["[object Function]"]=Xr["[object Map]"]=Xr[Jr]=Xr[Kr]=Xr[Lr]=Xr["[object Set]"]=Xr[Qr]=Xr["[object WeakMap]"]=false;var Yr={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Zr={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},nt={"function":true,object:true},rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tt=nt[typeof window]&&window||this,et=nt[typeof exports]&&exports&&!exports.nodeType&&exports,ut=nt[typeof module]&&module&&!module.nodeType&&module,ot=et&&ut&&typeof global=="object"&&global; +!ot||ot.global!==ot&&ot.window!==ot&&ot.self!==ot||(tt=ot);var it=ut&&ut.exports===et&&et,at=Array.prototype,ft=Object.prototype,ct=Function.prototype.toString,lt=ft.hasOwnProperty,pt=tt._,st=ft.toString,gt=RegExp("^"+function(n){return n=null==n?"":n+"",zr.lastIndex=0,zr.test(n)?n.replace(zr,"\\$&"):n}(st).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ht=Math.ceil,vt=Math.floor,yt=at.push,mt=ft.propertyIsEnumerable,bt=at.splice,_t=yr(_t=Object.create)&&_t,dt=yr(dt=Array.isArray)&&dt,jt=tt.isFinite,wt=yr(wt=Object.keys)&&wt,At=Math.max,xt=Math.min,Tt=yr(Tt=Date.now)&&Tt,Et=Math.random,Ot={}; +!function(){var n={0:1,length:1};Ot.spliceObjects=(bt.call(n,0,1),!n[0]);try{Ot.hostObject=!({toString:0}+"")}catch(r){Ot.hostObject=false}}(0,0),i.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},_t||(y=function(){function n(){}return function(r){if(vr(r)){n.prototype=r;var t=new n;n.prototype=null}return t||tt.Object()}}());var kt=P,St=C,It=M(function(n,r,t){lt.call(n,t)?++n[t]:n[t]=1}),Ft=M(function(n,r,t){lt.call(n,t)?n[t].push(r):n[t]=[r] +}),Mt=M(function(n,r,t){n[t]=r}),qt=M(function(n,r,t){n[t?0:1].push(r)},function(){return[[],[]]}),Bt=fr(function(n,r){var t;if(!hr(r))throw new TypeError(Mr);return function(){return 0<--n?t=r.apply(this,arguments):r=null,t}},2);sr(arguments)||(sr=function(n){var r=n&&typeof n=="object"?n.length:Or;return typeof r=="number"&&-1--n?r.apply(this,arguments):void 0}},i.bind=ir,i.bindAll=function(n){for(var r=n,t=1r?0:r)},i.intersection=function(){for(var n=[],r=-1,t=arguments.length;++ri(f,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;f.push(e)}return f},i.invert=function(n){for(var r=-1,t=Nt(n),e=t.length,u={};++ro?0:o>>>0);for(r=v(r,e,3),b(n,function(n,t,e){i[++u]={a:r(n,t,e),b:u,c:n}}),o=i.length,i.sort(t);o--;)i[o]=i[o].c;return i},i.take=St,i.tap=function(n,r){return r(n),n},i.throttle=function(n,r,t){var e=true,u=true;if(!hr(n))throw new TypeError(funcErrorText);return false===t?e=false:vr(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),ar(n,r,{leading:e,maxWait:r,trailing:u}) +},i.times=function(n,r,t){n=jt(n=+n)&&-1r?0:r))},i.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?At(e+t,0):xt(t||0,e-1))+1);e--;)if(n[e]===r)return e;return-1},i.max=nr,i.min=function(n,r,t){var e=1/0,u=e,o=typeof r; +if("number"!=o&&"string"!=o||!t||t[r]!==n||(r=null),null==r)for(t=-1,n=z(n),o=n.length;++tr?0:+r||0,n.length),n)},Tr(cr({},i)),i.VERSION="3.0.0-pre",i.prototype.chain=function(){return this.__chain__=true,this},i.prototype.value=function(){return this.__wrapped__ +},f("pop push reverse shift sort splice unshift".split(" "),function(n){var r=at[n];i.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Ot.spliceObjects||0!==n.length||delete n[0],this}}),f(["concat","join","slice"],function(n){var r=at[n];i.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new a(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(tt._=i, define("underscore",function(){return i +})):et&&ut?it?(ut.exports=i)._=i:et._=i:tt._=i}).call(this); \ No newline at end of file