diff --git a/.npm/package/npm-shrinkwrap.json b/.npm/package/npm-shrinkwrap.json index 32dc3f2..bedd367 100644 --- a/.npm/package/npm-shrinkwrap.json +++ b/.npm/package/npm-shrinkwrap.json @@ -1,7 +1,7 @@ { "dependencies": { "lodash": { - "version": "3.8.0" + "version": "3.9.3" } } } diff --git a/.versions b/.versions index 6694b10..7a53f05 100644 --- a/.versions +++ b/.versions @@ -7,15 +7,15 @@ ejson@1.0.6 geojson-utils@1.0.3 id-map@1.0.3 json@1.0.3 -local-test:stevezhu:lodash@3.7.0 +local-test:stevezhu:lodash@3.9.3 logging@1.0.7 -meteor@1.1.5 -minimongo@1.0.7 +meteor@1.1.6 +minimongo@1.0.8 mongo@1.1.0 ordered-dict@1.0.3 random@1.0.3 retry@1.0.3 -stevezhu:lodash@3.7.0 +stevezhu:lodash@3.9.3 tinytest@1.0.5 -tracker@1.0.6 +tracker@1.0.7 underscore@1.0.3 diff --git a/README.md b/README.md index ca2a665..aa15a57 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A meteor package for [lodash](http://lodash.com/). -Using lodash v3.6.0 +Using lodash v3.8.0 ## Usage diff --git a/lodash.js b/lodash.js index 2bed95a..58b2b06 100755 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.8.0 (Custom Build) + * lodash 3.9.3 (Custom Build) * Build: `lodash compat -o ./lodash.js` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.8.0'; + var VERSION = '3.9.3'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -118,6 +118,9 @@ /** Used to detect host constructors (Safari > 5). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; + /** Used to detect unsigned integer values. */ + var reIsUint = /^\d+$/; + /** Used to match latin-1 supplementary letters (excluding mathematical operators). */ var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; @@ -152,9 +155,8 @@ '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' + 'isFinite', 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 'window' ]; /** Used to fix the JScript `[[DontEnum]]` bug. */ @@ -281,29 +283,40 @@ /** * Used as a reference to the global object. * - * The `this` value is used if it is the global object to avoid Greasemonkey's + * The `this` value is used if it's the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; + /*--------------------------------------------------------------------------*/ + /** * The base implementation of `compareAscending` which compares values and * sorts them in ascending order without guaranteeing a stable sort. * * @private - * @param {*} value The value to compare to `other`. - * @param {*} other The value to compare to `value`. + * @param {*} value The value to compare. + * @param {*} other The other value to compare. * @returns {number} Returns the sort order indicator for `value`. */ function baseCompareAscending(value, other) { if (value !== other) { - var valIsReflexive = value === value, + var valIsNull = value === null, + valIsUndef = value === undefined, + valIsReflexive = value === value; + + var othIsNull = other === null, + othIsUndef = other === undefined, othIsReflexive = other === other; - if (value > other || !valIsReflexive || (value === undefined && othIsReflexive)) { + if ((value > other && !othIsNull) || !valIsReflexive || + (valIsNull && !othIsUndef && othIsReflexive) || + (valIsUndef && othIsReflexive)) { return 1; } - if (value < other || !othIsReflexive || (other === undefined && valIsReflexive)) { + if ((value < other && !valIsNull) || !othIsReflexive || + (othIsNull && !valIsUndef && valIsReflexive) || + (othIsUndef && valIsReflexive)) { return -1; } } @@ -371,7 +384,7 @@ } /** - * Converts `value` to a string if it is not one. An empty string is returned + * Converts `value` to a string if it's not one. An empty string is returned * for `null` or `undefined` values. * * @private @@ -385,17 +398,6 @@ return value == null ? '' : (value + ''); } - /** - * Used by `_.max` and `_.min` as the default callback for string values. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the code unit of the first character of the string. - */ - function charAtCallback(string) { - return string.charCodeAt(0); - } - /** * Used by `_.trim` and `_.trimLeft` to get the index of the first character * of `string` that is not found in `chars`. @@ -676,6 +678,8 @@ return htmlUnescapes[chr]; } + /*--------------------------------------------------------------------------*/ + /** * Create a new pristine `lodash` function using the given `context` object. * @@ -737,7 +741,7 @@ stringProto = String.prototype; /** Used to detect DOM support. */ - var document = (document = context.window) && document.document; + var document = (document = context.window) ? document.document : null; /** Used to resolve the decompiled source of functions. */ var fnToString = Function.prototype.toString; @@ -759,26 +763,25 @@ /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + - escapeRegExp(objToString) - .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' + escapeRegExp(fnToString.call(hasOwnProperty)) + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** Native method references. */ - var ArrayBuffer = isNative(ArrayBuffer = context.ArrayBuffer) && ArrayBuffer, - bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, + var ArrayBuffer = getNative(context, 'ArrayBuffer'), + bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'), ceil = Math.ceil, clearTimeout = context.clearTimeout, floor = Math.floor, - getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols, - getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, + getPrototypeOf = getNative(Object, 'getPrototypeOf'), + parseFloat = context.parseFloat, push = arrayProto.push, - preventExtensions = isNative(preventExtensions = Object.preventExtensions) && preventExtensions, propertyIsEnumerable = objectProto.propertyIsEnumerable, - Set = isNative(Set = context.Set) && Set, + Set = getNative(context, 'Set'), setTimeout = context.setTimeout, splice = arrayProto.splice, - Uint8Array = isNative(Uint8Array = context.Uint8Array) && Uint8Array, - WeakMap = isNative(WeakMap = context.WeakMap) && WeakMap; + Uint8Array = getNative(context, 'Uint8Array'), + WeakMap = getNative(context, 'WeakMap'); /** Used to clone array buffers. */ var Float64Array = (function() { @@ -786,44 +789,21 @@ // where the array buffer's `byteLength` is not a multiple of the typed // array's `BYTES_PER_ELEMENT`. try { - var func = isNative(func = context.Float64Array) && func, + var func = getNative(context, 'Float64Array'), result = new func(new ArrayBuffer(10), 0, 1) && func; } catch(e) {} - return result; - }()); - - /** Used as `baseAssign`. */ - var nativeAssign = (function() { - // Avoid `Object.assign` in Firefox 34-37 which have an early implementation - // with a now defunct try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344 - // for more details. - // - // Use `Object.preventExtensions` on a plain object instead of simply using - // `Object('x')` because Chrome and IE fail to throw an error when attempting - // to assign values to readonly indexes of strings. - var func = preventExtensions && isNative(func = Object.assign) && func; - try { - if (func) { - var object = preventExtensions({ '1': 0 }); - object[0] = 1; - } - } catch(e) { - // Only attempt in strict mode. - try { func(object, 'xo'); } catch(e) {} - return !object[1] && func; - } - return false; + return result || null; }()); /* Native method references for those with the same name as other `lodash` methods. */ - var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, - nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, + var nativeCreate = getNative(Object, 'create'), + nativeIsArray = getNative(Array, 'isArray'), nativeIsFinite = context.isFinite, - nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, + nativeKeys = getNative(Object, 'keys'), nativeMax = Math.max, nativeMin = Math.min, - nativeNow = isNative(nativeNow = Date.now) && nativeNow, - nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite, + nativeNow = getNative(Date, 'now'), + nativeNumIsFinite = getNative(Number, 'isFinite'), nativeParseInt = context.parseInt, nativeRandom = Math.random; @@ -832,7 +812,7 @@ POSITIVE_INFINITY = Number.POSITIVE_INFINITY; /** Used as references for the maximum length and index of an array. */ - var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, + var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; @@ -843,7 +823,7 @@ * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) * of an array-like value. */ - var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; + var MAX_SAFE_INTEGER = 9007199254740991; /** Used to store function metadata. */ var metaMap = WeakMap && new WeakMap; @@ -879,6 +859,8 @@ } }); + /*------------------------------------------------------------------------*/ + /** * Creates a `lodash` object which wraps `value` to enable implicit chaining. * Methods that operate on and return arrays, collections, and functions can @@ -918,30 +900,31 @@ * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, - * `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, - * `merge`, `mixin`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, - * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, - * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, - * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, - * `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, - * `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`, - * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, - * `without`, `wrap`, `xor`, `zip`, and `zipObject` + * `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`, + * `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`, + * `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`, + * `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`, + * `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`, + * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, + * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, + * `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`, + * `wrap`, `xor`, `zip`, `zipObject`, `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, - * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite` - * `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, - * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, - * `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`, - * `noop`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, - * `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, `startsWith`, - * `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, `unescape`, - * `uniqueId`, `value`, and `words` + * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`, + * `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, + * `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, + * `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, + * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`, + * `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`, + * `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, + * `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`, + * `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` * * The wrapper method `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. @@ -1018,7 +1001,6 @@ (function(x) { var Ctor = function() { this.x = x; }, - args = arguments, object = { '0': x, 'length': x }, props = []; @@ -1032,7 +1014,7 @@ * @memberOf _.support * @type boolean */ - support.argsTag = objToString.call(args) == argsTag; + support.argsTag = objToString.call(arguments) == argsTag; /** * Detect if `name` or `message` properties of `Error.prototype` are @@ -1057,24 +1039,6 @@ */ support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype'); - /** - * Detect if functions can be decompiled by `Function#toString` - * (all but Firefox OS certified apps, older Opera mobile browsers, and - * the PlayStation 3; forced `false` for Windows 8 apps). - * - * @memberOf _.support - * @type boolean - */ - support.funcDecomp = /\bthis\b/.test(function() { return this; }); - - /** - * Detect if `Function#name` is supported (all but IE). - * - * @memberOf _.support - * @type boolean - */ - support.funcNames = typeof Function.name == 'string'; - /** * Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9). * @@ -1083,14 +1047,6 @@ */ support.nodeTag = objToString.call(document) != objectTag; - /** - * Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal). - * - * @memberOf _.support - * @type boolean - */ - support.nonEnumStrings = !propertyIsEnumerable.call('x', 0); - /** * Detect if properties shadowing those on `Object.prototype` are non-enumerable. * @@ -1147,24 +1103,6 @@ } catch(e) { support.dom = false; } - - /** - * Detect if `arguments` object indexes are non-enumerable. - * - * In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object - * indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat - * `arguments` object indexes as non-enumerable and fail `hasOwnProperty` - * checks for indexes that exceed the number of function parameters and - * whose associated argument values are `0`. - * - * @memberOf _.support - * @type boolean - */ - try { - support.nonEnumArgs = !propertyIsEnumerable.call(args, 1); - } catch(e) { - support.nonEnumArgs = true; - } }(1, 0)); /** @@ -1228,6 +1166,8 @@ } }; + /*------------------------------------------------------------------------*/ + /** * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. * @@ -1356,6 +1296,8 @@ return result; } + /*------------------------------------------------------------------------*/ + /** * Creates a cache object to store key/value pairs. * @@ -1424,6 +1366,8 @@ return this; } + /*------------------------------------------------------------------------*/ + /** * * Creates a cache object to store unique values. @@ -1473,6 +1417,8 @@ } } + /*------------------------------------------------------------------------*/ + /** * Copies the values of `source` to `array`. * @@ -1555,6 +1501,35 @@ return true; } + /** + * A specialized version of `baseExtremum` for arrays which invokes `iteratee` + * with one argument: (value). + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. + * @returns {*} Returns the extremum value. + */ + function arrayExtremum(array, iteratee, comparator, exValue) { + var index = -1, + length = array.length, + computed = exValue, + result = computed; + + while (++index < length) { + var value = array[index], + current = +iteratee(value); + + if (comparator(current, computed)) { + computed = current; + result = value; + } + } + return result; + } + /** * A specialized version of `_.filter` for arrays without support for callback * shorthands and `this` binding. @@ -1599,48 +1574,6 @@ return result; } - /** - * A specialized version of `_.max` for arrays without support for iteratees. - * - * @private - * @param {Array} array The array to iterate over. - * @returns {*} Returns the maximum value. - */ - function arrayMax(array) { - var index = -1, - length = array.length, - result = NEGATIVE_INFINITY; - - while (++index < length) { - var value = array[index]; - if (value > result) { - result = value; - } - } - return result; - } - - /** - * A specialized version of `_.min` for arrays without support for iteratees. - * - * @private - * @param {Array} array The array to iterate over. - * @returns {*} Returns the minimum value. - */ - function arrayMin(array) { - var index = -1, - length = array.length, - result = POSITIVE_INFINITY; - - while (++index < length) { - var value = array[index]; - if (value < result) { - result = value; - } - } - return result; - } - /** * A specialized version of `_.reduce` for arrays without support for callback * shorthands and `this` binding. @@ -1771,10 +1704,8 @@ * @returns {Object} Returns `object`. */ function assignWith(object, source, customizer) { - var props = keys(source); - push.apply(props, getSymbols(source)); - var index = -1, + props = keys(source), length = props.length; while (++index < length) { @@ -1799,11 +1730,11 @@ * @param {Object} source The source object. * @returns {Object} Returns `object`. */ - var baseAssign = nativeAssign || function(object, source) { + function baseAssign(object, source) { return source == null ? object - : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object)); - }; + : baseCopy(source, keys(source), object); + } /** * The base implementation of `_.at` without support for string collections @@ -1818,7 +1749,7 @@ var index = -1, isNil = collection == null, isArr = !isNil && isArrayLike(collection), - length = isArr && collection.length, + length = isArr ? collection.length : 0, propsLength = props.length, result = Array(propsLength); @@ -1962,14 +1893,14 @@ * @returns {Object} Returns the new object. */ var baseCreate = (function() { - function Object() {} + function object() {} return function(prototype) { if (isObject(prototype)) { - Object.prototype = prototype; - var result = new Object; - Object.prototype = null; + object.prototype = prototype; + var result = new object; + object.prototype = null; } - return result || context.Object(); + return result || {}; }; }()); @@ -2078,6 +2009,32 @@ return result; } + /** + * Gets the extremum value of `collection` invoking `iteratee` for each value + * in `collection` to generate the criterion by which the value is ranked. + * The `iteratee` is invoked with three arguments: (value, index|key, collection). + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. + * @returns {*} Returns the extremum value. + */ + function baseExtremum(collection, iteratee, comparator, exValue) { + var computed = exValue, + result = computed; + + baseEach(collection, function(value, index, collection) { + var current = +iteratee(value, index, collection); + if (comparator(current, computed) || (current === exValue && current === result)) { + computed = current; + result = value; + } + }); + return result; + } + /** * The base implementation of `_.fill` without an iteratee call guard. * @@ -2295,11 +2252,11 @@ if (pathKey !== undefined && pathKey in object) { path = [pathKey]; } - var index = -1, + var index = 0, length = path.length; - while (object != null && ++index < length) { - object = toObject(object)[path[index]]; + while (object != null && index < length) { + object = toObject(object)[path[index++]]; } return (index && index == length) ? object : undefined; } @@ -2318,17 +2275,10 @@ * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { - // Exit early for identical values. if (value === other) { return true; } - var valType = typeof value, - othType = typeof other; - - // Exit early for unlike primitive values. - if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') || - value == null || other == null) { - // Return `false` unless both values are `NaN`. + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { return value !== value && other !== other; } return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); @@ -2379,11 +2329,11 @@ return equalByTag(object, other, objTag); } if (!isLoose) { - var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - if (valWrapped || othWrapped) { - return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); } } if (!isSameTag) { @@ -2418,42 +2368,44 @@ * * @private * @param {Object} object The object to inspect. - * @param {Array} props The source property names to match. - * @param {Array} values The source values to match. - * @param {Array} strictCompareFlags Strict comparison flags for source values. + * @param {Array} matchData The propery names, values, and compare flags to match. * @param {Function} [customizer] The function to customize comparing objects. * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ - function baseIsMatch(object, props, values, strictCompareFlags, customizer) { - var index = -1, - length = props.length, + function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, + length = index, noCustomizer = !customizer; - while (++index < length) { - if ((noCustomizer && strictCompareFlags[index]) - ? values[index] !== object[props[index]] - : !(props[index] in object) + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) ) { return false; } } - index = -1; while (++index < length) { - var key = props[index], + data = matchData[index]; + var key = data[0], objValue = object[key], - srcValue = values[index]; + srcValue = data[1]; - if (noCustomizer && strictCompareFlags[index]) { - var result = objValue !== undefined || (key in object); + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } } else { - result = customizer ? customizer(objValue, srcValue, key) : undefined; - if (result === undefined) { - result = baseIsEqual(srcValue, objValue, customizer, true); + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; } } - if (!result) { - return false; - } } return true; } @@ -2485,51 +2437,35 @@ * @returns {Function} Returns the new function. */ function baseMatches(source) { - var props = keys(source), - length = props.length; - - if (!length) { - return constant(true); - } - if (length == 1) { - var key = props[0], - value = source[key]; - - if (isStrictComparable(value)) { - return function(object) { - if (object == null) { - return false; - } - object = toObject(object); - return object[key] === value && (value !== undefined || (key in object)); - }; - } - } - var values = Array(length), - strictCompareFlags = Array(length); + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], + value = matchData[0][1]; - while (length--) { - value = source[props[length]]; - values[length] = value; - strictCompareFlags[length] = isStrictComparable(value); + return function(object) { + if (object == null) { + return false; + } + object = toObject(object); + return object[key] === value && (value !== undefined || (key in object)); + }; } return function(object) { - return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags); + return baseIsMatch(object, matchData); }; } /** - * The base implementation of `_.matchesProperty` which does not which does - * not clone `value`. + * The base implementation of `_.matchesProperty` which does not clone `srcValue`. * * @private * @param {string} path The path of the property to get. - * @param {*} value The value to compare. + * @param {*} srcValue The value to compare. * @returns {Function} Returns the new function. */ - function baseMatchesProperty(path, value) { + function baseMatchesProperty(path, srcValue) { var isArr = isArray(path), - isCommon = isKey(path) && isStrictComparable(value), + isCommon = isKey(path) && isStrictComparable(srcValue), pathKey = (path + ''); path = toPath(path); @@ -2547,9 +2483,9 @@ key = last(path); object = toObject(object); } - return object[key] === value - ? (value !== undefined || (key in object)) - : baseIsEqual(value, object[key], null, true); + return object[key] === srcValue + ? (srcValue !== undefined || (key in object)) + : baseIsEqual(srcValue, object[key], undefined, true); }; } @@ -2569,11 +2505,9 @@ if (!isObject(object)) { return object; } - var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)); - if (!isSrcArr) { - var props = keys(source); - push.apply(props, getSymbols(source)); - } + var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), + props = isSrcArr ? null : keys(source); + arrayEach(props || source, function(srcValue, key) { if (props) { key = srcValue; @@ -2592,7 +2526,7 @@ if (isCommon) { result = srcValue; } - if ((isSrcArr || result !== undefined) && + if ((result !== undefined || (isSrcArr && !(key in object))) && (isCommon || (result === result ? (result !== value) : (value === value)))) { object[key] = result; } @@ -2699,7 +2633,7 @@ function basePullAt(array, indexes) { var length = array ? indexes.length : 0; while (length--) { - var index = parseFloat(indexes[length]); + var index = indexes[length]; if (index != previous && isIndex(index)) { var previous = index; splice.call(array, index, 1); @@ -3012,7 +2946,7 @@ var mid = (low + high) >>> 1, computed = array[mid]; - if (retHighest ? (computed <= value) : (computed < value)) { + if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { low = mid + 1; } else { high = mid; @@ -3042,17 +2976,23 @@ var low = 0, high = array ? array.length : 0, valIsNaN = value !== value, + valIsNull = value === null, valIsUndef = value === undefined; while (low < high) { var mid = floor((low + high) / 2), computed = iteratee(array[mid]), + isDef = computed !== undefined, isReflexive = computed === computed; if (valIsNaN) { var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); } else if (valIsUndef) { - setLow = isReflexive && (retHighest || computed !== undefined); + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; } else { setLow = retHighest ? (computed <= value) : (computed < value); } @@ -3242,19 +3182,19 @@ return restParam(function(object, sources) { var index = -1, length = object == null ? 0 : sources.length, - customizer = length > 2 && sources[length - 2], - guard = length > 2 && sources[2], - thisArg = length > 1 && sources[length - 1]; + customizer = length > 2 ? sources[length - 2] : undefined, + guard = length > 2 ? sources[2] : undefined, + thisArg = length > 1 ? sources[length - 1] : undefined; if (typeof customizer == 'function') { customizer = bindCallback(customizer, thisArg, 5); length -= 2; } else { - customizer = typeof thisArg == 'function' ? thisArg : null; + customizer = typeof thisArg == 'function' ? thisArg : undefined; length -= (customizer ? 1 : 0); } if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? null : customizer; + customizer = length < 3 ? undefined : customizer; length = 1; } while (++index < length) { @@ -3379,8 +3319,20 @@ */ function createCtorWrapper(Ctor) { return function() { + // Use a `switch` statement to work with class constructors. + // See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + } var thisBinding = baseCreate(Ctor.prototype), - result = Ctor.apply(thisBinding, arguments); + result = Ctor.apply(thisBinding, args); // Mimic the constructor's `return` behavior. // See https://es5.github.io/#x13.2.2 for more details. @@ -3411,32 +3363,24 @@ * Creates a `_.max` or `_.min` function. * * @private - * @param {Function} arrayFunc The function to get the extremum value from an array. - * @param {boolean} [isMin] Specify returning the minimum, instead of the maximum, - * extremum value. + * @param {Function} comparator The function used to compare values. + * @param {*} exValue The initial extremum value. * @returns {Function} Returns the new extremum function. */ - function createExtremum(arrayFunc, isMin) { + function createExtremum(comparator, exValue) { return function(collection, iteratee, thisArg) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = null; } - var func = getCallback(), - noIteratee = iteratee == null; - - if (!(func === baseCallback && noIteratee)) { - noIteratee = false; - iteratee = func(iteratee, thisArg, 3); - } - if (noIteratee) { - var isArr = isArray(collection); - if (!isArr && isString(collection)) { - iteratee = charAtCallback; - } else { - return arrayFunc(isArr ? collection : toIterable(collection)); + iteratee = getCallback(iteratee, thisArg, 3); + if (iteratee.length == 1) { + collection = toIterable(collection); + var result = arrayExtremum(collection, iteratee, comparator, exValue); + if (!(collection.length && result === exValue)) { + return result; } } - return extremumBy(collection, iteratee, isMin); + return baseExtremum(collection, iteratee, comparator, exValue); }; } @@ -3499,11 +3443,8 @@ */ function createFlow(fromRight) { return function() { - var length = arguments.length; - if (!length) { - return function() { return arguments[0]; }; - } var wrapper, + length = arguments.length, index = fromRight ? length : -1, leftIndex = 0, funcs = Array(length); @@ -3513,15 +3454,17 @@ if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - var funcName = wrapper ? '' : getFuncName(func); - wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper; + if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') { + wrapper = new LodashWrapper([]); + } } index = wrapper ? -1 : length; while (++index < length) { func = funcs[index]; - funcName = getFuncName(func); - var data = funcName == 'wrapper' ? getData(func) : null; + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : null; + if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); } else { @@ -3534,7 +3477,7 @@ return wrapper.plant(args[0]).value(); } var index = 0, - result = funcs[index].apply(this, args); + result = length ? funcs[index].apply(this, args) : args[0]; while (++index < length) { result = funcs[index].call(this, result); @@ -3683,10 +3626,8 @@ isBindKey = bitmask & BIND_KEY_FLAG, isCurry = bitmask & CURRY_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG, - isCurryRight = bitmask & CURRY_RIGHT_FLAG; - - var Ctor = !isBindKey && createCtorWrapper(func), - key = func; + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + Ctor = isBindKey ? null : createCtorWrapper(func); function wrapper() { // Avoid `arguments` object use disqualifying optimizations by @@ -3733,17 +3674,18 @@ return result; } } - var thisBinding = isBind ? thisArg : this; - if (isBindKey) { - func = thisBinding[key]; - } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; + if (argPos) { args = reorder(args, argPos); } if (isAry && ary < args.length) { args.length = ary; } - var fn = (this && this !== root && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func; + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } return fn.apply(thisBinding, args); } return wrapper; @@ -3817,10 +3759,10 @@ */ function createSortedIndex(retHighest) { return function(array, value, iteratee, thisArg) { - var func = getCallback(iteratee); - return (func === baseCallback && iteratee == null) + var callback = getCallback(iteratee); + return (iteratee == null && callback === baseCallback) ? binaryIndex(array, value, retHighest) - : binaryIndexBy(array, value, func(iteratee, thisArg, 1), retHighest); + : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); }; } @@ -3906,40 +3848,35 @@ function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { var index = -1, arrLength = array.length, - othLength = other.length, - result = true; + othLength = other.length; if (arrLength != othLength && !(isLoose && othLength > arrLength)) { return false; } - // Deep compare the contents, ignoring non-numeric properties. - while (result && ++index < arrLength) { + // Ignore non-index properties. + while (++index < arrLength) { var arrValue = array[index], - othValue = other[index]; - - result = undefined; - if (customizer) { - result = isLoose - ? customizer(othValue, arrValue, index) - : customizer(arrValue, othValue, index); - } - if (result === undefined) { - // Recursively compare arrays (susceptible to call stack limits). - if (isLoose) { - var othIndex = othLength; - while (othIndex--) { - othValue = other[othIndex]; - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); - if (result) { - break; - } - } - } else { - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + othValue = other[index], + result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + + if (result !== undefined) { + if (result) { + continue; } + return false; + } + // Recursively compare arrays (susceptible to call stack limits). + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; } } - return !!result; + return true; } /** @@ -4004,29 +3941,22 @@ if (objLength != othLength && !isLoose) { return false; } - var skipCtor = isLoose, - index = -1; - + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var skipCtor = isLoose; while (++index < objLength) { - var key = objProps[index], - result = isLoose ? key in other : hasOwnProperty.call(other, key); + key = objProps[index]; + var objValue = object[key], + othValue = other[key], + result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; - if (result) { - var objValue = object[key], - othValue = other[key]; - - result = undefined; - if (customizer) { - result = isLoose - ? customizer(othValue, objValue, key) - : customizer(objValue, othValue, key); - } - if (result === undefined) { - // Recursively compare objects (susceptible to call stack limits). - result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB); - } - } - if (!result) { + // Recursively compare objects (susceptible to call stack limits). + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { return false; } skipCtor || (skipCtor = key == 'constructor'); @@ -4046,34 +3976,6 @@ return true; } - /** - * Gets the extremum value of `collection` invoking `iteratee` for each value - * in `collection` to generate the criterion by which the value is ranked. - * The `iteratee` is invoked with three arguments: (value, index, collection). - * - * @private - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {boolean} [isMin] Specify returning the minimum, instead of the - * maximum, extremum value. - * @returns {*} Returns the extremum value. - */ - function extremumBy(collection, iteratee, isMin) { - var exValue = isMin ? POSITIVE_INFINITY : NEGATIVE_INFINITY, - computed = exValue, - result = computed; - - baseEach(collection, function(value, index, collection) { - var current = iteratee(value, index, collection); - if ((isMin ? (current < computed) : (current > computed)) || - (current === exValue && current === result)) { - computed = current; - result = value; - } - }); - return result; - } - /** * Gets the appropriate "callback" function. If the `_.callback` method is * customized this function returns the custom method, otherwise it returns @@ -4107,29 +4009,20 @@ * @param {Function} func The function to query. * @returns {string} Returns the function name. */ - var getFuncName = (function() { - if (!support.funcNames) { - return constant(''); - } - if (constant.name == 'constant') { - return baseProperty('name'); - } - return function(func) { - var result = func.name, - array = realNames[result], - length = array ? array.length : 0; - - while (length--) { - var data = array[length], - otherFunc = data.func; + function getFuncName(func) { + var result = func.name, + array = realNames[result], + length = array ? array.length : 0; - if (otherFunc == null || otherFunc == func) { - return data.name; - } + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; } - return result; - }; - }()); + } + return result; + } /** * Gets the appropriate "indexOf" function. If the `_.indexOf` method is @@ -4159,15 +4052,34 @@ var getLength = baseProperty('length'); /** - * Creates an array of the own symbols of `object`. + * Gets the propery names, values, and compare flags of `object`. * * @private * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. + * @returns {Array} Returns the match data of `object`. */ - var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) { - return getOwnPropertySymbols(toObject(object)); - }; + function getMatchData(object) { + var result = pairs(object), + length = result.length; + + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; + } + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; + } /** * Gets the view, applying any `transforms` to the `start` and `end` positions. @@ -4313,7 +4225,7 @@ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { - value = +value; + value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; length = length == null ? MAX_SAFE_INTEGER : length; return value > -1 && value % 1 == 0 && value < length; } @@ -4370,7 +4282,15 @@ */ function isLaziable(func) { var funcName = getFuncName(func); - return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype; + if (!(funcName in LazyWrapper.prototype)) { + return false; + } + var other = lodash[funcName]; + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; } /** @@ -4618,12 +4538,10 @@ function shimKeys(object) { var props = keysIn(object), propsLength = props.length, - length = propsLength && object.length, - support = lodash.support; + length = propsLength && object.length; - var allowIndexes = length && isLength(length) && - (isArray(object) || (support.nonEnumStrings && isString(object)) || - (support.nonEnumArgs && isArguments(object))); + var allowIndexes = !!length && isLength(length) && + (isArray(object) || isArguments(object) || isString(object)); var index = -1, result = []; @@ -4638,7 +4556,7 @@ } /** - * Converts `value` to an array-like object if it is not one. + * Converts `value` to an array-like object if it's not one. * * @private * @param {*} value The value to process. @@ -4658,7 +4576,7 @@ } /** - * Converts `value` to an object if it is not one. + * Converts `value` to an object if it's not one. * * @private * @param {*} value The value to process. @@ -4679,7 +4597,7 @@ } /** - * Converts `value` to property path array if it is not one. + * Converts `value` to property path array if it's not one. * * @private * @param {*} value The value to process. @@ -4709,6 +4627,8 @@ : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); } + /*------------------------------------------------------------------------*/ + /** * 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 @@ -4776,8 +4696,8 @@ } /** - * Creates an array excluding all values of the provided arrays using - * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * Creates an array of unique `array` values not included in the other + * provided arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * for equality comparisons. * * @static @@ -5250,8 +5170,8 @@ } /** - * Creates an array of unique values in all provided arrays using - * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * Creates an array of unique values that are included in all of the provided + * arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * for equality comparisons. * * @static @@ -5263,27 +5183,19 @@ * _.intersection([1, 2], [4, 2], [2, 1]); * // => [2] */ - function intersection() { - var args = [], - argsIndex = -1, - argsLength = arguments.length, - caches = [], + var intersection = restParam(function(arrays) { + var othLength = arrays.length, + othIndex = othLength, + caches = Array(length), indexOf = getIndexOf(), isCommon = indexOf == baseIndexOf, result = []; - while (++argsIndex < argsLength) { - var value = arguments[argsIndex]; - if (isArrayLike(value)) { - args.push(value); - caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null); - } + while (othIndex--) { + var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; + caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; } - argsLength = args.length; - if (argsLength < 2) { - return result; - } - var array = args[0], + var array = arrays[0], index = -1, length = array ? array.length : 0, seen = caches[0]; @@ -5292,10 +5204,10 @@ while (++index < length) { value = array[index]; if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { - argsIndex = argsLength; - while (--argsIndex) { - var cache = caches[argsIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) { + var othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) { continue outer; } } @@ -5306,7 +5218,7 @@ } } return result; - } + }); /** * Gets the last element of `array`. @@ -5812,8 +5724,8 @@ } /** - * Creates an array of unique values, in order, of the provided arrays using - * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * Creates an array of unique values, in order, from all of the provided arrays + * using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * for equality comparisons. * * @static @@ -5889,9 +5801,9 @@ iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; } - var func = getCallback(); - if (!(func === baseCallback && iteratee == null)) { - iteratee = func(iteratee, thisArg, 3); + var callback = getCallback(); + if (!(iteratee == null && callback === baseCallback)) { + iteratee = callback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() == baseIndexOf) ? sortedUniq(array, iteratee) @@ -5994,7 +5906,7 @@ }); /** - * Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) + * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * of the provided arrays. * * @static @@ -6098,8 +6010,8 @@ */ var zipWith = restParam(function(arrays) { var length = arrays.length, - iteratee = arrays[length - 2], - thisArg = arrays[length - 1]; + iteratee = length > 2 ? arrays[length - 2] : undefined, + thisArg = length > 1 ? arrays[length - 1] : undefined; if (length > 2 && typeof iteratee == 'function') { length -= 2; @@ -6111,6 +6023,8 @@ return unzipWith(arrays, iteratee, thisArg); }); + /*------------------------------------------------------------------------*/ + /** * Creates a `lodash` object that wraps `value` with explicit method * chaining enabled. @@ -6361,6 +6275,8 @@ return baseWrapperValue(this.__wrapped__, this.__actions__); } + /*------------------------------------------------------------------------*/ + /** * Creates an array of elements corresponding to the given keys, or indexes, * of `collection`. Keys may be specified as individual arguments or as arrays @@ -6855,7 +6771,7 @@ }); /** - * Invokes the method at `path` on each element in `collection`, returning + * Invokes the method at `path` of each element in `collection`, returning * an array of the results of each invoked method. Any additional arguments * are provided to each invoked method. If `methodName` is a function it is * invoked for, and `this` bound to, each element in `collection`. @@ -6883,7 +6799,7 @@ result = isArrayLike(collection) ? Array(collection.length) : []; baseEach(collection, function(value) { - var func = isFunc ? path : (isProp && value != null && value[path]); + var func = isFunc ? path : ((isProp && value != null) ? value[path] : null); result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); }); return result; @@ -6905,7 +6821,7 @@ * callback returns `true` for elements that have the properties of the given * object, else `false`. * - * Many lodash methods are guarded to work as interatees for methods like + * Many lodash methods are guarded to work as iteratees for methods like * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * * The guarded methods are: @@ -7049,7 +6965,7 @@ * value. The `iteratee` is bound to `thisArg` and invoked with four arguments: * (accumulator, value, index|key, collection). * - * Many lodash methods are guarded to work as interatees for methods like + * Many lodash methods are guarded to work as iteratees for methods like * `_.reduce`, `_.reduceRight`, and `_.transform`. * * The guarded methods are: @@ -7171,8 +7087,20 @@ var length = collection.length; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; } - var result = shuffle(collection); - result.length = nativeMin(n < 0 ? 0 : (+n || 0), result.length); + var index = -1, + result = toArray(collection), + length = result.length, + lastIndex = length - 1; + + n = nativeMin(n < 0 ? 0 : (+n || 0), length); + while (++index < n) { + var rand = baseRandom(index, lastIndex), + value = result[rand]; + + result[rand] = result[index]; + result[index] = value; + } + result.length = n; return result; } @@ -7191,20 +7119,7 @@ * // => [4, 1, 3, 2] */ function shuffle(collection) { - collection = toIterable(collection); - - var index = -1, - length = collection.length, - result = Array(length); - - while (++index < length) { - var rand = baseRandom(0, index); - if (index != rand) { - result[index] = result[rand]; - } - result[rand] = collection[index]; - } - return result; + return sample(collection, POSITIVE_INFINITY); } /** @@ -7485,6 +7400,8 @@ return filter(collection, baseMatches(source)); } + /*------------------------------------------------------------------------*/ + /** * Gets the number of milliseconds that have elapsed since the Unix epoch * (1 January 1970 00:00:00 UTC). @@ -7503,6 +7420,8 @@ return new Date().getTime(); }; + /*------------------------------------------------------------------------*/ + /** * The opposite of `_.before`; this method creates a function that invokes * `func` once it is called `n` or more times. @@ -7826,12 +7745,13 @@ var curryRight = createCurry(CURRY_RIGHT_FLAG); /** - * Creates a function that delays invoking `func` until after `wait` milliseconds - * have elapsed since the last time it was invoked. The created function comes - * with a `cancel` method to cancel delayed invocations. Provide an options - * object to indicate that `func` should be invoked on the leading and/or - * trailing edge of the `wait` timeout. Subsequent calls to the debounced - * function return the result of the last `func` invocation. + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed invocations. Provide an options object to indicate that `func` + * should be invoked on the leading and/or trailing edge of the `wait` timeout. + * Subsequent calls to the debounced function return the result of the last + * `func` invocation. * * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * on the trailing edge of the timeout only if the the debounced function is @@ -8145,14 +8065,14 @@ } var memoized = function() { var args = arguments, - cache = memoized.cache, - key = resolver ? resolver.apply(this, args) : args[0]; + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); - cache.set(key, result); + memoized.cache = cache.set(key, result); return result; }; memoized.cache = new memoize.Cache; @@ -8399,12 +8319,12 @@ } /** - * Creates a function that only invokes `func` at most once per every `wait` - * milliseconds. The created function comes with a `cancel` method to cancel - * delayed invocations. Provide an options object to indicate that `func` - * should be invoked on the leading and/or trailing edge of the `wait` timeout. - * Subsequent calls to the throttled function return the result of the last - * `func` call. + * Creates a throttled function that only invokes `func` at most once per + * every `wait` milliseconds. The throttled function comes with a `cancel` + * method to cancel delayed invocations. Provide an options object to indicate + * that `func` should be invoked on the leading and/or trailing edge of the + * `wait` timeout. Subsequent calls to the throttled function return the + * result of the last `func` call. * * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * on the trailing edge of the timeout only if the the throttled function is @@ -8482,6 +8402,8 @@ return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []); } + /*------------------------------------------------------------------------*/ + /** * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, * otherwise they are assigned by reference. If `customizer` is provided it is @@ -8542,8 +8464,9 @@ customizer = isDeep; isDeep = false; } - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); - return baseClone(value, isDeep, customizer); + return typeof customizer == 'function' + ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1)) + : baseClone(value, isDeep); } /** @@ -8592,8 +8515,57 @@ * // => 20 */ function cloneDeep(value, customizer, thisArg) { - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); - return baseClone(value, true, customizer); + return typeof customizer == 'function' + ? baseClone(value, true, bindCallback(customizer, thisArg, 1)) + : baseClone(value, true); + } + + /** + * Checks if `value` is greater than `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`. + * @example + * + * _.gt(3, 1); + * // => true + * + * _.gt(3, 3); + * // => false + * + * _.gt(1, 3); + * // => false + */ + function gt(value, other) { + return value > other; + } + + /** + * Checks if `value` is greater than or equal to `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`. + * @example + * + * _.gte(3, 1); + * // => true + * + * _.gte(3, 3); + * // => true + * + * _.gte(1, 3); + * // => false + */ + function gte(value, other) { + return value >= other; } /** @@ -8763,6 +8735,7 @@ * * @static * @memberOf _ + * @alias eq * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. @@ -8792,12 +8765,9 @@ * // => true */ function isEqual(value, other, customizer, thisArg) { - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); - if (!customizer && isStrictComparable(value) && isStrictComparable(other)) { - return value === other; - } + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; var result = customizer ? customizer(value, other) : undefined; - return result === undefined ? baseIsEqual(value, other, customizer) : !!result; + return result === undefined ? baseIsEqual(value, other, customizer) : !!result; } /** @@ -8899,7 +8869,7 @@ // Avoid a V8 JIT bug in Chrome 19-20. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. var type = typeof value; - return type == 'function' || (!!value && type == 'object'); + return !!value && (type == 'object' || type == 'function'); } /** @@ -8942,33 +8912,8 @@ * // => true */ function isMatch(object, source, customizer, thisArg) { - var props = keys(source), - length = props.length; - - if (!length) { - return true; - } - if (object == null) { - return false; - } - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); - object = toObject(object); - if (!customizer && length == 1) { - var key = props[0], - value = source[key]; - - if (isStrictComparable(value)) { - return value === object[key] && (value !== undefined || (key in object)); - } - } - var values = Array(length), - strictCompareFlags = Array(length); - - while (length--) { - value = values[length] = source[props[length]]; - strictCompareFlags[length] = isStrictComparable(value); - } - return baseIsMatch(object, props, values, strictCompareFlags, customizer); + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; + return baseIsMatch(object, getMatchData(source), customizer); } /** @@ -9108,8 +9053,8 @@ if (!(value && objToString.call(value) == objectTag) || (!lodash.support.argsTag && isArguments(value))) { return false; } - var valueOf = value.valueOf, - objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); + var valueOf = getNative(value, 'valueOf'), + objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); return objProto ? (value == objProto || getPrototypeOf(value) == objProto) @@ -9196,6 +9141,54 @@ return value === undefined; } + /** + * Checks if `value` is less than `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`. + * @example + * + * _.lt(1, 3); + * // => true + * + * _.lt(3, 3); + * // => false + * + * _.lt(3, 1); + * // => false + */ + function lt(value, other) { + return value < other; + } + + /** + * Checks if `value` is less than or equal to `other`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`. + * @example + * + * _.lte(1, 3); + * // => true + * + * _.lte(3, 3); + * // => true + * + * _.lte(3, 1); + * // => false + */ + function lte(value, other) { + return value <= other; + } + /** * Converts `value` to an array. * @@ -9251,6 +9244,8 @@ return baseCopy(value, keysIn(value)); } + /*------------------------------------------------------------------------*/ + /** * Assigns own enumerable properties of source object(s) to the destination * object. Subsequent sources overwrite property assignments of previous sources. @@ -9590,7 +9585,7 @@ } /** - * Gets the property value of `path` on `object`. If the resolved value is + * Gets the property value at `path` of `object`. If the resolved value is * `undefined` the `defaultValue` is used in its place. * * @static @@ -9648,10 +9643,14 @@ if (!result && !isKey(path)) { path = toPath(path); object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } path = last(path); - result = object != null && hasOwnProperty.call(object, path); + result = hasOwnProperty.call(object, path); } - return result || (lodash.support.nonEnumStrings && isString(object) && isIndex(path, object.length)); + return result || (isLength(object.length) && isIndex(path, object.length) && + (isArray(object) || isArguments(object) || isString(object))); } /** @@ -9732,7 +9731,7 @@ * // => ['0', '1'] */ var keys = !nativeKeys ? shimKeys : function(object) { - var Ctor = object != null && object.constructor; + var Ctor = object == null ? null : object.constructor; if ((typeof Ctor == 'function' && Ctor.prototype === object) || (typeof object == 'function' ? lodash.support.enumPrototypes : isArrayLike(object))) { return shimKeys(object); @@ -9773,8 +9772,7 @@ support = lodash.support; length = (length && isLength(length) && - (isArray(object) || (support.nonEnumStrings && isString(object)) || - (support.nonEnumArgs && isArguments(object))) && length) || 0; + (isArray(object) || isArguments(object) || isString(object)) && length) || 0; var Ctor = object.constructor, index = -1, @@ -9987,6 +9985,8 @@ * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) */ function pairs(object) { + object = toObject(object); + var index = -1, props = keys(object), length = props.length, @@ -10107,13 +10107,13 @@ var index = -1, length = path.length, - endIndex = length - 1, + lastIndex = length - 1, nested = object; while (nested != null && ++index < length) { var key = path[index]; if (isObject(nested)) { - if (index == endIndex) { + if (index == lastIndex) { nested[key] = value; } else if (nested[key] == null) { nested[key] = isIndex(path[index + 1]) ? [] : {}; @@ -10163,7 +10163,7 @@ if (isArr) { accumulator = isArray(object) ? new Ctor : []; } else { - accumulator = baseCreate(isFunction(Ctor) && Ctor.prototype); + accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null); } } else { accumulator = {}; @@ -10231,6 +10231,8 @@ return baseValues(object, keysIn(object)); } + /*------------------------------------------------------------------------*/ + /** * Checks if `n` is between `start` and up to but not including, `end`. If * `end` is not specified it is set to `start` with `start` then set to `0`. @@ -10335,6 +10337,8 @@ return baseRandom(min, max); } + /*------------------------------------------------------------------------*/ + /** * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). * @@ -10438,7 +10442,7 @@ * use a third-party library like [_he_](https://mths.be/he). * * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't require escaping in HTML and have no special meaning + * ">" and "/" don't need escaping in HTML and have no special meaning * unless they're part of a tag or unquoted attribute value. * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) * (under "semi-related fun fact") for more details. @@ -10515,7 +10519,7 @@ }); /** - * Pads `string` on the left and right sides if it is shorter than `length`. + * Pads `string` on the left and right sides if it's shorter than `length`. * Padding characters are truncated if they can't be evenly divided by `length`. * * @static @@ -10553,7 +10557,7 @@ } /** - * Pads `string` on the left side if it is shorter than `length`. Padding + * Pads `string` on the left side if it's shorter than `length`. Padding * characters are truncated if they exceed `length`. * * @static @@ -10577,7 +10581,7 @@ var padLeft = createPadDir(); /** - * Pads `string` on the right side if it is shorter than `length`. Padding + * Pads `string` on the right side if it's shorter than `length`. Padding * characters are truncated if they exceed `length`. * * @static @@ -11058,7 +11062,7 @@ } /** - * Truncates `string` if it is longer than the given maximum string length. + * Truncates `string` if it's longer than the given maximum string length. * The last characters of the truncated string are replaced with the omission * string which defaults to "...". * @@ -11200,6 +11204,8 @@ return string.match(pattern || reWords) || []; } + /*------------------------------------------------------------------------*/ + /** * Attempts to invoke `func`, returning either the result or the caught error * object. Any additional arguments are provided to `func` when it is invoked. @@ -11317,7 +11323,7 @@ } /** - * Creates a function which performs a deep comparison between a given object + * Creates a function that performs a deep comparison between a given object * and `source`, returning `true` if the given object has equivalent property * values, else `false`. * @@ -11346,7 +11352,7 @@ } /** - * Creates a function which compares the property value of `path` on a given + * Creates a function that compares the property value of `path` on a given * object to `value`. * * **Note:** This method supports comparing arrays, booleans, `Date` objects, @@ -11357,7 +11363,7 @@ * @memberOf _ * @category Utility * @param {Array|string} path The path of the property to get. - * @param {*} value The value to compare. + * @param {*} srcValue The value to match. * @returns {Function} Returns the new function. * @example * @@ -11369,17 +11375,19 @@ * _.find(users, _.matchesProperty('user', 'fred')); * // => { 'user': 'fred' } */ - function matchesProperty(path, value) { - return baseMatchesProperty(path, baseClone(value, true)); + function matchesProperty(path, srcValue) { + return baseMatchesProperty(path, baseClone(srcValue, true)); } /** - * Creates a function which invokes the method at `path` on a given object. + * Creates a function that invokes the method at `path` on a given object. + * Any additional arguments are provided to the invoked method. * * @static * @memberOf _ * @category Utility * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. * @returns {Function} Returns the new function. * @example * @@ -11401,13 +11409,15 @@ }); /** - * The opposite of `_.method`; this method creates a function which invokes - * the method at a given path on `object`. + * The opposite of `_.method`; this method creates a function that invokes + * the method at a given path on `object`. Any additional arguments are + * provided to the invoked method. * * @static * @memberOf _ * @category Utility * @param {Object} object The object to query. + * @param {...*} [args] The arguments to invoke the method with. * @returns {Function} Returns the new function. * @example * @@ -11451,9 +11461,6 @@ * }); * } * - * // use `_.runInContext` to avoid conflicts (esp. in Node.js) - * var _ = require('lodash').runInContext(); - * * _.mixin({ 'vowels': vowels }); * _.vowels('fred'); * // => ['e'] @@ -11468,8 +11475,8 @@ function mixin(object, source, options) { if (options == null) { var isObj = isObject(source), - props = isObj && keys(source), - methodNames = props && props.length && baseFunctions(source, props); + props = isObj ? keys(source) : null, + methodNames = (props && props.length) ? baseFunctions(source, props) : null; if (!(methodNames ? methodNames.length : isObj)) { methodNames = false; @@ -11536,7 +11543,7 @@ } /** - * A no-operation function which returns `undefined` regardless of the + * A no-operation function that returns `undefined` regardless of the * arguments it receives. * * @static @@ -11554,7 +11561,7 @@ } /** - * Creates a function which returns the property value at `path` on a + * Creates a function that returns the property value at `path` on a * given object. * * @static @@ -11580,7 +11587,7 @@ } /** - * The opposite of `_.property`; this method creates a function which returns + * The opposite of `_.property`; this method creates a function that returns * the property value at a given path on `object`. * * @static @@ -11734,6 +11741,8 @@ return baseToString(prefix) + id; } + /*------------------------------------------------------------------------*/ + /** * Adds two numbers. * @@ -11799,7 +11808,7 @@ * _.max(users, 'age'); * // => { 'user': 'fred', 'age': 40 } */ - var max = createExtremum(arrayMax); + var max = createExtremum(gt, NEGATIVE_INFINITY); /** * Gets the minimum value of `collection`. If `collection` is empty or falsey @@ -11848,7 +11857,7 @@ * _.min(users, 'age'); * // => { 'user': 'barney', 'age': 36 } */ - var min = createExtremum(arrayMin, true); + var min = createExtremum(lt, POSITIVE_INFINITY); /** * Gets the sum of the values in `collection`. @@ -11886,18 +11895,20 @@ if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = null; } - var func = getCallback(), + var callback = getCallback(), noIteratee = iteratee == null; - if (!(func === baseCallback && noIteratee)) { + if (!(noIteratee && callback === baseCallback)) { noIteratee = false; - iteratee = func(iteratee, thisArg, 3); + iteratee = callback(iteratee, thisArg, 3); } return noIteratee ? arraySum(isArray(collection) ? collection : toIterable(collection)) : baseSum(collection, iteratee); } + /*------------------------------------------------------------------------*/ + // Ensure wrappers are instances of `baseLodash`. lodash.prototype = baseLodash.prototype; @@ -12045,6 +12056,8 @@ // Add functions to `lodash.prototype`. mixin(lodash, lodash); + /*------------------------------------------------------------------------*/ + // Add functions that return unwrapped values when chaining. lodash.add = add; lodash.attempt = attempt; @@ -12066,6 +12079,8 @@ lodash.findWhere = findWhere; lodash.first = first; lodash.get = get; + lodash.gt = gt; + lodash.gte = gte; lodash.has = has; lodash.identity = identity; lodash.includes = includes; @@ -12095,6 +12110,8 @@ lodash.kebabCase = kebabCase; lodash.last = last; lodash.lastIndexOf = lastIndexOf; + lodash.lt = lt; + lodash.lte = lte; lodash.max = max; lodash.min = min; lodash.noConflict = noConflict; @@ -12131,6 +12148,7 @@ lodash.all = every; lodash.any = some; lodash.contains = includes; + lodash.eq = isEqual; lodash.detect = find; lodash.foldl = reduce; lodash.foldr = reduceRight; @@ -12148,6 +12166,8 @@ return source; }()), false); + /*------------------------------------------------------------------------*/ + // Add functions capable of returning wrapped and unwrapped values when chaining. lodash.sample = sample; @@ -12160,6 +12180,8 @@ }); }; + /*------------------------------------------------------------------------*/ + /** * The semantic version number. * @@ -12343,7 +12365,7 @@ retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName); // Avoid array-like object bugs with `Array#shift` and `Array#splice` in - // IE < 9, Firefox < 10, Narwhal, and RingoJS. + // IE < 9, Firefox < 10, and RingoJS. var func = !fixObjects ? protoFunc : function() { var result = protoFunc.apply(this, arguments); if (this.length === 0) { @@ -12398,6 +12420,8 @@ return lodash; } + /*--------------------------------------------------------------------------*/ + // Export lodash. var _ = runInContext(); @@ -12421,7 +12445,7 @@ if (moduleExports) { (freeModule.exports = _)._ = _; } - // Export for Narwhal or Rhino -require. + // Export for Rhino with CommonJS support. else { freeExports._ = _; } diff --git a/package.js b/package.js index f4f0616..d18da33 100755 --- a/package.js +++ b/package.js @@ -1,9 +1,9 @@ -Npm.depends({'lodash': '3.8.0'}); +Npm.depends({'lodash': '3.9.3'}); Package.describe({ name: "stevezhu:lodash", summary: "A utility library delivering consistency, customization, performance, & extras.", - version: "3.8.0", + version: "3.9.3", git: "https://github.com/stevezhu/meteor-lodash.git" });