diff --git a/README.md b/README.md index d6a9495d8..1f769e3a1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-amd v4.14.0 +# lodash-amd v4.14.1 The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. @@ -27,4 +27,4 @@ require({ }); ``` -See the [package source](https://github.com/lodash/lodash/tree/4.14.0-amd) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.14.1-amd) for more details. diff --git a/_baseClone.js b/_baseClone.js index 57b138c31..b0711e0b8 100644 --- a/_baseClone.js +++ b/_baseClone.js @@ -120,9 +120,6 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_clone // Recursively populate clone (susceptible to call stack limits). assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - if (!isFull) { - stack['delete'](value); - } return result; } diff --git a/_createRange.js b/_createRange.js index 2a3143571..02ddbe2e8 100644 --- a/_createRange.js +++ b/_createRange.js @@ -1,4 +1,4 @@ -define(['./_baseRange', './_isIterateeCall', './toNumber'], function(baseRange, isIterateeCall, toNumber) { +define(['./_baseRange', './_isIterateeCall', './toFinite'], function(baseRange, isIterateeCall, toFinite) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -16,15 +16,14 @@ define(['./_baseRange', './_isIterateeCall', './toNumber'], function(baseRange, end = step = undefined; } // Ensure the sign of `-0` is preserved. - start = toNumber(start); - start = start === start ? start : 0; + start = toFinite(start); if (end === undefined) { end = start; start = 0; } else { - end = toNumber(end) || 0; + end = toFinite(end); } - step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0); + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); return baseRange(start, end, step, fromRight); }; } diff --git a/_equalArrays.js b/_equalArrays.js index d4612aecf..c67d2fc85 100644 --- a/_equalArrays.js +++ b/_equalArrays.js @@ -78,6 +78,7 @@ define(['./_SetCache', './_arraySome'], function(SetCache, arraySome) { } } stack['delete'](array); + stack['delete'](other); return result; } diff --git a/_equalObjects.js b/_equalObjects.js index 1d3a1f955..94c4a9a60 100644 --- a/_equalObjects.js +++ b/_equalObjects.js @@ -80,6 +80,7 @@ define(['./_baseHas', './keys'], function(baseHas, keys) { } } stack['delete'](object); + stack['delete'](other); return result; } diff --git a/_getSymbolsIn.js b/_getSymbolsIn.js index 70653943a..f7f9cb270 100644 --- a/_getSymbolsIn.js +++ b/_getSymbolsIn.js @@ -1,4 +1,4 @@ -define(['./_arrayPush', './_getPrototype', './_getSymbols'], function(arrayPush, getPrototype, getSymbols) { +define(['./_arrayPush', './_getPrototype', './_getSymbols', './stubArray'], function(arrayPush, getPrototype, getSymbols, stubArray) { /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; @@ -11,7 +11,7 @@ define(['./_arrayPush', './_getPrototype', './_getSymbols'], function(arrayPush, * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbolsIn = !nativeGetSymbols ? getSymbols : function(object) { + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); diff --git a/_isFlattenable.js b/_isFlattenable.js index 6efe010bb..ded2da8b8 100644 --- a/_isFlattenable.js +++ b/_isFlattenable.js @@ -15,7 +15,7 @@ define(['./_Symbol', './isArguments', './isArray'], function(Symbol, isArguments */ function isFlattenable(value) { return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]) + !!(spreadableSymbol && value && value[spreadableSymbol]); } return isFlattenable; diff --git a/_nodeUtil.js b/_nodeUtil.js index 48738eef0..8e1cb7aa4 100644 --- a/_nodeUtil.js +++ b/_nodeUtil.js @@ -1,10 +1,10 @@ define(['./_freeGlobal'], function(freeGlobal) { /** Detect free variable `exports`. */ - var freeExports = freeGlobal && typeof exports == 'object' && exports; + var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ - var freeModule = freeExports && typeof module == 'object' && module; + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; diff --git a/_stringToPath.js b/_stringToPath.js index 19fed0a4e..19af02d13 100644 --- a/_stringToPath.js +++ b/_stringToPath.js @@ -1,7 +1,8 @@ define(['./memoize', './toString'], function(memoize, toString) { /** Used to match property names within property paths. */ - var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g; + var reLeadingDot = /^\./, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; @@ -14,8 +15,13 @@ define(['./memoize', './toString'], function(memoize, toString) { * @returns {Array} Returns the property path array. */ var stringToPath = memoize(function(string) { + string = toString(string); + var result = []; - toString(string).replace(rePropName, function(match, number, quote, string) { + if (reLeadingDot.test(string)) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, string) { result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); }); return result; diff --git a/conforms.js b/conforms.js index 82d28236c..f5d9fb3fd 100644 --- a/conforms.js +++ b/conforms.js @@ -5,6 +5,9 @@ define(['./_baseClone', './_baseConforms'], function(baseClone, baseConforms) { * the corresponding property values of a given object, returning `true` if * all predicates return truthy, else `false`. * + * **Note:** The created function is equivalent to `_.conformsTo` with + * `source` partially applied. + * * @static * @memberOf _ * @since 4.0.0 diff --git a/conformsTo.js b/conformsTo.js index 901c62f39..fb3f381eb 100644 --- a/conformsTo.js +++ b/conformsTo.js @@ -1,9 +1,11 @@ define(['./_baseConformsTo', './keys'], function(baseConformsTo, keys) { /** - * Checks if `object` conforms to `source` by invoking the predicate properties - * of `source` with the corresponding property values of `object`. This method - * is equivalent to a `_.conforms` function when `source` is partially applied. + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. * * @static * @memberOf _ diff --git a/debounce.js b/debounce.js index 98486a936..2973d9779 100644 --- a/debounce.js +++ b/debounce.js @@ -15,14 +15,18 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber) * milliseconds have elapsed since the last time the debounced function was * invoked. The debounced function comes with a `cancel` method to cancel * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide an options object to indicate whether `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent calls - * to the debounced function return the result of the last `func` invocation. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. 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 debounced function is - * invoked more than once during the `wait` timeout. + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.debounce` and `_.throttle`. diff --git a/inRange.js b/inRange.js index ceeaf0499..aa9ecac66 100644 --- a/inRange.js +++ b/inRange.js @@ -1,4 +1,4 @@ -define(['./_baseInRange', './toNumber'], function(baseInRange, toNumber) { +define(['./_baseInRange', './toFinite', './toNumber'], function(baseInRange, toFinite, toNumber) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -42,12 +42,12 @@ define(['./_baseInRange', './toNumber'], function(baseInRange, toNumber) { * // => true */ function inRange(number, start, end) { - start = toNumber(start) || 0; + start = toFinite(start); if (end === undefined) { end = start; start = 0; } else { - end = toNumber(end) || 0; + end = toFinite(end); } number = toNumber(number); return baseInRange(number, start, end); diff --git a/isBuffer.js b/isBuffer.js index fa2cc9091..81ce96a92 100644 --- a/isBuffer.js +++ b/isBuffer.js @@ -1,13 +1,13 @@ -define(['./_freeGlobal', './_root', './stubFalse'], function(freeGlobal, root, stubFalse) { +define(['./_root', './stubFalse'], function(root, stubFalse) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Detect free variable `exports`. */ - var freeExports = freeGlobal && typeof exports == 'object' && exports; + var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ - var freeModule = freeExports && typeof module == 'object' && module; + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; diff --git a/isMatch.js b/isMatch.js index 7bac32ec8..89e317ead 100644 --- a/isMatch.js +++ b/isMatch.js @@ -2,10 +2,10 @@ define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData /** * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. This method is - * equivalent to a `_.matches` function when `source` is partially applied. + * determine if `object` contains equivalent property values. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** This method supports comparing the same values as `_.isEqual` + * and is equivalent to `_.matches` when `source` is partially applied. * * @static * @memberOf _ diff --git a/main.js b/main.js index 3c62a92c3..c9c37e6a7 100644 --- a/main.js +++ b/main.js @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.14.0'; + var VERSION = '4.14.1'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -130,7 +130,8 @@ /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g; + reLeadingDot = /^\./, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** * Used to match `RegExp` @@ -371,10 +372,10 @@ var root = freeGlobal || freeSelf || Function('return this')(); /** Detect free variable `exports`. */ - var freeExports = freeGlobal && typeof exports == 'object' && exports; + var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ - var freeModule = freeExports && typeof module == 'object' && module; + var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; @@ -2415,9 +2416,6 @@ // Recursively populate clone (susceptible to call stack limits). assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); - if (!isFull) { - stack['delete'](value); - } return result; } @@ -5009,15 +5007,14 @@ end = step = undefined; } // Ensure the sign of `-0` is preserved. - start = toNumber(start); - start = start === start ? start : 0; + start = toFinite(start); if (end === undefined) { end = start; start = 0; } else { - end = toNumber(end) || 0; + end = toFinite(end); } - step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0); + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); return baseRange(start, end, step, fromRight); }; } @@ -5290,6 +5287,7 @@ } } stack['delete'](array); + stack['delete'](other); return result; } @@ -5450,6 +5448,7 @@ } } stack['delete'](object); + stack['delete'](other); return result; } @@ -5625,7 +5624,7 @@ * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ - var getSymbolsIn = !nativeGetSymbols ? getSymbols : function(object) { + var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); @@ -5863,7 +5862,7 @@ */ function isFlattenable(value) { return isArray(value) || isArguments(value) || - !!(spreadableSymbol && value && value[spreadableSymbol]) + !!(spreadableSymbol && value && value[spreadableSymbol]); } /** @@ -6216,8 +6215,13 @@ * @returns {Array} Returns the property path array. */ var stringToPath = memoize(function(string) { + string = toString(string); + var result = []; - toString(string).replace(rePropName, function(match, number, quote, string) { + if (reLeadingDot.test(string)) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, string) { result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); }); return result; @@ -9779,14 +9783,18 @@ * milliseconds have elapsed since the last time the debounced function was * invoked. The debounced function comes with a `cancel` method to cancel * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide an options object to indicate whether `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent calls - * to the debounced function return the result of the last `func` invocation. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. 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 debounced function is - * invoked more than once during the `wait` timeout. + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.debounce` and `_.throttle`. @@ -10374,8 +10382,8 @@ * 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 `func` invocations and a `flush` method to - * immediately invoke them. Provide an options object to indicate whether - * `func` should be invoked on the leading and/or trailing edge of the `wait` + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` * timeout. The `func` is invoked with the last arguments provided to the * throttled function. Subsequent calls to the throttled function return the * result of the last `func` invocation. @@ -10384,6 +10392,9 @@ * invoked on the trailing edge of the timeout only if the throttled function * is invoked more than once during the `wait` timeout. * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.throttle` and `_.debounce`. * @@ -10638,9 +10649,11 @@ } /** - * Checks if `object` conforms to `source` by invoking the predicate properties - * of `source` with the corresponding property values of `object`. This method - * is equivalent to a `_.conforms` function when `source` is partially applied. + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. * * @static * @memberOf _ @@ -11308,10 +11321,10 @@ /** * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. This method is - * equivalent to a `_.matches` function when `source` is partially applied. + * determine if `object` contains equivalent property values. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** This method supports comparing the same values as `_.isEqual` + * and is equivalent to `_.matches` when `source` is partially applied. * * @static * @memberOf _ @@ -13523,12 +13536,12 @@ * // => true */ function inRange(number, start, end) { - start = toNumber(start) || 0; + start = toFinite(start); if (end === undefined) { end = start; start = 0; } else { - end = toNumber(end) || 0; + end = toFinite(end); } number = toNumber(number); return baseInRange(number, start, end); @@ -13584,12 +13597,12 @@ upper = 1; } else { - lower = toNumber(lower) || 0; + lower = toFinite(lower); if (upper === undefined) { upper = lower; lower = 0; } else { - upper = toNumber(upper) || 0; + upper = toFinite(upper); } } if (lower > upper) { @@ -14836,6 +14849,9 @@ * the corresponding property values of a given object, returning `true` if * all predicates return truthy, else `false`. * + * **Note:** The created function is equivalent to `_.conformsTo` with + * `source` partially applied. + * * @static * @memberOf _ * @since 4.0.0 @@ -15021,10 +15037,10 @@ /** * Creates a function that performs a partial deep comparison between a given * object and `source`, returning `true` if the given object has equivalent - * property values, else `false`. The created function is equivalent to - * `_.isMatch` with a `source` partially applied. + * property values, else `false`. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** The created function supports comparing the same values as + * `_.isEqual` is equivalent to `_.isMatch` with `source` partially applied. * * @static * @memberOf _ diff --git a/matches.js b/matches.js index 8487fe63c..86bdf909e 100644 --- a/matches.js +++ b/matches.js @@ -3,10 +3,10 @@ define(['./_baseClone', './_baseMatches'], function(baseClone, baseMatches) { /** * Creates a function that performs a partial deep comparison between a given * object and `source`, returning `true` if the given object has equivalent - * property values, else `false`. The created function is equivalent to - * `_.isMatch` with a `source` partially applied. + * property values, else `false`. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** The created function supports comparing the same values as + * `_.isEqual` is equivalent to `_.isMatch` with `source` partially applied. * * @static * @memberOf _ diff --git a/package.json b/package.json index 8b4665154..b2d9eeefb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-amd", - "version": "4.14.0", + "version": "4.14.1", "description": "Lodash exported as AMD modules.", "keywords": "amd, modules, stdlib, util", "homepage": "https://lodash.com/custom-builds", diff --git a/random.js b/random.js index 17378ed29..a84447dde 100644 --- a/random.js +++ b/random.js @@ -1,4 +1,4 @@ -define(['./_baseRandom', './_isIterateeCall', './toNumber'], function(baseRandom, isIterateeCall, toNumber) { +define(['./_baseRandom', './_isIterateeCall', './toFinite'], function(baseRandom, isIterateeCall, toFinite) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -60,12 +60,12 @@ define(['./_baseRandom', './_isIterateeCall', './toNumber'], function(baseRandom upper = 1; } else { - lower = toNumber(lower) || 0; + lower = toFinite(lower); if (upper === undefined) { upper = lower; lower = 0; } else { - upper = toNumber(upper) || 0; + upper = toFinite(upper); } } if (lower > upper) { diff --git a/throttle.js b/throttle.js index d49e00016..2697a1177 100644 --- a/throttle.js +++ b/throttle.js @@ -7,8 +7,8 @@ define(['./debounce', './isObject'], function(debounce, isObject) { * 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 `func` invocations and a `flush` method to - * immediately invoke them. Provide an options object to indicate whether - * `func` should be invoked on the leading and/or trailing edge of the `wait` + * immediately invoke them. Provide `options` to indicate whether `func` + * should be invoked on the leading and/or trailing edge of the `wait` * timeout. The `func` is invoked with the last arguments provided to the * throttled function. Subsequent calls to the throttled function return the * result of the last `func` invocation. @@ -17,6 +17,9 @@ define(['./debounce', './isObject'], function(debounce, isObject) { * invoked on the trailing edge of the timeout only if the throttled function * is invoked more than once during the `wait` timeout. * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.throttle` and `_.debounce`. *