diff --git a/README.md b/README.md index 402a960b6..23d4ddd11 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-es v4.3.0 +# lodash-es v4.4.0 The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules. @@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): $ lodash modularize exports=es -o ./ ``` -See the [package source](https://github.com/lodash/lodash/tree/4.3.0-es) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.4.0-es) for more details. diff --git a/_Hash.js b/_Hash.js index 73c741b58..0848848de 100644 --- a/_Hash.js +++ b/_Hash.js @@ -7,6 +7,7 @@ var objectProto = Object.prototype; * Creates an hash object. * * @private + * @constructor * @returns {Object} Returns the new hash object. */ function Hash() {} diff --git a/_LazyWrapper.js b/_LazyWrapper.js index 95a49dbd5..9a4a2ad50 100644 --- a/_LazyWrapper.js +++ b/_LazyWrapper.js @@ -8,6 +8,7 @@ var MAX_ARRAY_LENGTH = 4294967295; * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. * * @private + * @constructor * @param {*} value The value to wrap. */ function LazyWrapper(value) { diff --git a/_MapCache.js b/_MapCache.js index a0d716575..3ca6da713 100644 --- a/_MapCache.js +++ b/_MapCache.js @@ -8,6 +8,7 @@ import mapSet from './_mapSet'; * Creates a map cache object to store key-value pairs. * * @private + * @constructor * @param {Array} [values] The values to cache. */ function MapCache(values) { diff --git a/_SetCache.js b/_SetCache.js index 30b2ebd1d..616f7c036 100644 --- a/_SetCache.js +++ b/_SetCache.js @@ -6,6 +6,7 @@ import cachePush from './_cachePush'; * Creates a set cache object to store unique values. * * @private + * @constructor * @param {Array} [values] The values to cache. */ function SetCache(values) { diff --git a/_Stack.js b/_Stack.js index cb06511b8..50b7ebb56 100644 --- a/_Stack.js +++ b/_Stack.js @@ -8,6 +8,7 @@ import stackSet from './_stackSet'; * Creates a stack cache object to store key-value pairs. * * @private + * @constructor * @param {Array} [values] The values to cache. */ function Stack(values) { diff --git a/_baseCastArrayLikeObject.js b/_baseCastArrayLikeObject.js new file mode 100644 index 000000000..3c139b2bb --- /dev/null +++ b/_baseCastArrayLikeObject.js @@ -0,0 +1,14 @@ +import isArrayLikeObject from './isArrayLikeObject'; + +/** + * Casts `value` to an empty array if it's not an array like object. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array} Returns the array-like object. + */ +function baseCastArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; +} + +export default baseCastArrayLikeObject; diff --git a/_baseCastFunction.js b/_baseCastFunction.js new file mode 100644 index 000000000..dfa272ecc --- /dev/null +++ b/_baseCastFunction.js @@ -0,0 +1,14 @@ +import identity from './identity'; + +/** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array} Returns the array-like object. + */ +function baseCastFunction(value) { + return typeof value == 'function' ? value : identity; +} + +export default baseCastFunction; diff --git a/_baseCastPath.js b/_baseCastPath.js new file mode 100644 index 000000000..41c7ecdd6 --- /dev/null +++ b/_baseCastPath.js @@ -0,0 +1,15 @@ +import isArray from './isArray'; +import stringToPath from './_stringToPath'; + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast property path array. + */ +function baseCastPath(value) { + return isArray(value) ? value : stringToPath(value); +} + +export default baseCastPath; diff --git a/_baseCreate.js b/_baseCreate.js index 98c576034..95945bbb7 100644 --- a/_baseCreate.js +++ b/_baseCreate.js @@ -1,5 +1,8 @@ import isObject from './isObject'; +/** Built-in value references. */ +var objectCreate = Object.create; + /** * The base implementation of `_.create` without support for assigning * properties to the created object. @@ -8,16 +11,8 @@ import isObject from './isObject'; * @param {Object} prototype The object to inherit from. * @returns {Object} Returns the new object. */ -var baseCreate = (function() { - function object() {} - return function(prototype) { - if (isObject(prototype)) { - object.prototype = prototype; - var result = new object; - object.prototype = undefined; - } - return result || {}; - }; -}()); +function baseCreate(proto) { + return isObject(proto) ? objectCreate(proto) : {}; +} export default baseCreate; diff --git a/_baseFlatten.js b/_baseFlatten.js index d668ae5b4..f9ea40749 100644 --- a/_baseFlatten.js +++ b/_baseFlatten.js @@ -8,12 +8,12 @@ import isArrayLikeObject from './isArrayLikeObject'; * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. + * @param {number} depth The maximum recursion depth. * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ -function baseFlatten(array, isDeep, isStrict, result) { +function baseFlatten(array, depth, isStrict, result) { result || (result = []); var index = -1, @@ -21,11 +21,11 @@ function baseFlatten(array, isDeep, isStrict, result) { while (++index < length) { var value = array[index]; - if (isArrayLikeObject(value) && + if (depth > 0 && isArrayLikeObject(value) && (isStrict || isArray(value) || isArguments(value))) { - if (isDeep) { + if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, isDeep, isStrict, result); + baseFlatten(value, depth - 1, isStrict, result); } else { arrayPush(result, value); } diff --git a/_baseGet.js b/_baseGet.js index e64234fbf..93383ecfd 100644 --- a/_baseGet.js +++ b/_baseGet.js @@ -1,4 +1,4 @@ -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import isKey from './_isKey'; /** @@ -10,7 +10,7 @@ import isKey from './_isKey'; * @returns {*} Returns the resolved value. */ function baseGet(object, path) { - path = isKey(path, object) ? [path + ''] : baseToPath(path); + path = isKey(path, object) ? [path + ''] : baseCastPath(path); var index = 0, length = path.length; diff --git a/_baseIntersection.js b/_baseIntersection.js index d5a3ded07..1a20c3437 100644 --- a/_baseIntersection.js +++ b/_baseIntersection.js @@ -42,11 +42,17 @@ function baseIntersection(arrays, iteratee, comparator) { var value = array[index], computed = iteratee ? iteratee(value) : value; - if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { + if (!(seen + ? cacheHas(seen, computed) + : includes(result, computed, comparator) + )) { var othIndex = othLength; while (--othIndex) { var cache = caches[othIndex]; - if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) { + if (!(cache + ? cacheHas(cache, computed) + : includes(arrays[othIndex], computed, comparator)) + ) { continue outer; } } diff --git a/_baseInvoke.js b/_baseInvoke.js index e64cca0d0..8ba20a268 100644 --- a/_baseInvoke.js +++ b/_baseInvoke.js @@ -1,5 +1,5 @@ import apply from './_apply'; -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import isKey from './_isKey'; import last from './last'; import parent from './_parent'; @@ -16,7 +16,7 @@ import parent from './_parent'; */ function baseInvoke(object, path, args) { if (!isKey(path, object)) { - path = baseToPath(path); + path = baseCastPath(path); object = parent(object, path); path = last(path); } diff --git a/_baseKeys.js b/_baseKeys.js index a683bc126..7e3b31eb6 100644 --- a/_baseKeys.js +++ b/_baseKeys.js @@ -6,7 +6,6 @@ var nativeKeys = Object.keys; * property of prototypes or treat sparse arrays as dense. * * @private - * @type Function * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ diff --git a/_baseMerge.js b/_baseMerge.js index 388e059af..0869eacdd 100644 --- a/_baseMerge.js +++ b/_baseMerge.js @@ -21,7 +21,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } - var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source); + var props = (isArray(source) || isTypedArray(source)) + ? undefined + : keysIn(source); + arrayEach(props || source, function(srcValue, key) { if (props) { key = srcValue; @@ -32,7 +35,10 @@ function baseMerge(object, source, srcIndex, customizer, stack) { baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { - var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined; + var newValue = customizer + ? customizer(object[key], srcValue, (key + ''), object, source, stack) + : undefined; + if (newValue === undefined) { newValue = srcValue; } diff --git a/_baseMergeDeep.js b/_baseMergeDeep.js index c1ad501fe..828330172 100644 --- a/_baseMergeDeep.js +++ b/_baseMergeDeep.js @@ -33,21 +33,24 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta assignMergeValue(object, key, stacked); return; } - var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined, - isCommon = newValue === undefined; + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; if (isCommon) { newValue = srcValue; if (isArray(srcValue) || isTypedArray(srcValue)) { if (isArray(objValue)) { - newValue = srcIndex ? copyArray(objValue) : objValue; + newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } else { isCommon = false; - newValue = baseClone(srcValue); + newValue = baseClone(srcValue, true); } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { @@ -56,10 +59,10 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta } else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { isCommon = false; - newValue = baseClone(srcValue); + newValue = baseClone(srcValue, true); } else { - newValue = srcIndex ? baseClone(objValue) : objValue; + newValue = objValue; } } else { diff --git a/_basePullAt.js b/_basePullAt.js index 8f50662bd..470afcbcc 100644 --- a/_basePullAt.js +++ b/_basePullAt.js @@ -1,4 +1,4 @@ -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import isIndex from './_isIndex'; import isKey from './_isKey'; import last from './last'; @@ -31,7 +31,7 @@ function basePullAt(array, indexes) { splice.call(array, index, 1); } else if (!isKey(index, array)) { - var path = baseToPath(index), + var path = baseCastPath(index), object = parent(array, path); if (object != null) { diff --git a/_baseSet.js b/_baseSet.js index 6b04422e0..de4debfd3 100644 --- a/_baseSet.js +++ b/_baseSet.js @@ -1,5 +1,5 @@ import assignValue from './_assignValue'; -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import isIndex from './_isIndex'; import isKey from './_isKey'; import isObject from './isObject'; @@ -15,7 +15,7 @@ import isObject from './isObject'; * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { - path = isKey(path, object) ? [path + ''] : baseToPath(path); + path = isKey(path, object) ? [path + ''] : baseCastPath(path); var index = -1, length = path.length, @@ -30,7 +30,9 @@ function baseSet(object, path, value, customizer) { var objValue = nested[key]; newValue = customizer ? customizer(objValue, key, nested) : undefined; if (newValue === undefined) { - newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue; + newValue = objValue == null + ? (isIndex(path[index + 1]) ? [] : {}) + : objValue; } } assignValue(nested, key, newValue); diff --git a/_baseToPath.js b/_baseToPath.js deleted file mode 100644 index a7ccdd7b1..000000000 --- a/_baseToPath.js +++ /dev/null @@ -1,16 +0,0 @@ -import isArray from './isArray'; -import stringToPath from './_stringToPath'; - -/** - * The base implementation of `_.toPath` which only converts `value` to a - * path if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Array} Returns the property path array. - */ -function baseToPath(value) { - return isArray(value) ? value : stringToPath(value); -} - -export default baseToPath; diff --git a/_baseUnset.js b/_baseUnset.js index 5743c1188..6666c9c54 100644 --- a/_baseUnset.js +++ b/_baseUnset.js @@ -1,4 +1,4 @@ -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import has from './has'; import isKey from './_isKey'; import last from './last'; @@ -13,7 +13,7 @@ import parent from './_parent'; * @returns {boolean} Returns `true` if the property is deleted, else `false`. */ function baseUnset(object, path) { - path = isKey(path, object) ? [path + ''] : baseToPath(path); + path = isKey(path, object) ? [path + ''] : baseCastPath(path); object = parent(object, path); var key = last(path); return (object != null && has(object, key)) ? delete object[key] : true; diff --git a/_cloneTypedArray.js b/_cloneTypedArray.js index 2fe9d7d6b..b1f8f6890 100644 --- a/_cloneTypedArray.js +++ b/_cloneTypedArray.js @@ -9,10 +9,11 @@ import cloneArrayBuffer from './_cloneArrayBuffer'; * @returns {Object} Returns the cloned typed array. */ function cloneTypedArray(typedArray, isDeep) { - var buffer = typedArray.buffer, + var arrayBuffer = typedArray.buffer, + buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer, Ctor = typedArray.constructor; - return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); + return new Ctor(buffer, typedArray.byteOffset, typedArray.length); } export default cloneTypedArray; diff --git a/_copyObjectWith.js b/_copyObjectWith.js index faf39e4a0..596505be6 100644 --- a/_copyObjectWith.js +++ b/_copyObjectWith.js @@ -18,8 +18,11 @@ function copyObjectWith(source, props, object, customizer) { length = props.length; while (++index < length) { - var key = props[index], - newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key]; + var key = props[index]; + + var newValue = customizer + ? customizer(object[key], source[key], key, object, source) + : source[key]; assignValue(object, key, newValue); } diff --git a/_createAssigner.js b/_createAssigner.js index 9efc8ed99..ef06868ea 100644 --- a/_createAssigner.js +++ b/_createAssigner.js @@ -15,7 +15,10 @@ function createAssigner(assigner) { customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined; - customizer = typeof customizer == 'function' ? (length--, customizer) : undefined; + customizer = typeof customizer == 'function' + ? (length--, customizer) + : undefined; + if (guard && isIterateeCall(sources[0], sources[1], guard)) { customizer = length < 3 ? undefined : customizer; length = 1; diff --git a/_createCaseFirst.js b/_createCaseFirst.js index 68dbe741d..69684d3b8 100644 --- a/_createCaseFirst.js +++ b/_createCaseFirst.js @@ -24,8 +24,11 @@ function createCaseFirst(methodName) { return function(string) { string = toString(string); - var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined, - chr = strSymbols ? strSymbols[0] : string.charAt(0), + var strSymbols = reHasComplexSymbol.test(string) + ? stringToArray(string) + : undefined; + + var chr = strSymbols ? strSymbols[0] : string.charAt(0), trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1); return chr[methodName]() + trailing; diff --git a/_createFlow.js b/_createFlow.js index 8f8765bbd..635c423db 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -27,7 +27,7 @@ var FUNC_ERROR_TEXT = 'Expected a function'; */ function createFlow(fromRight) { return rest(function(funcs) { - funcs = baseFlatten(funcs); + funcs = baseFlatten(funcs, 1); var length = funcs.length, index = length, @@ -52,7 +52,10 @@ function createFlow(fromRight) { var funcName = getFuncName(func), data = funcName == 'wrapper' ? getData(func) : undefined; - if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { + 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 { wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); @@ -62,7 +65,8 @@ function createFlow(fromRight) { var args = arguments, value = args[0]; - if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { + if (wrapper && args.length == 1 && + isArray(value) && value.length >= LARGE_ARRAY_SIZE) { return wrapper.plant(value).value(); } var index = 0, diff --git a/_createHybridWrapper.js b/_createHybridWrapper.js index b6be32937..c88c8e6c4 100644 --- a/_createHybridWrapper.js +++ b/_createHybridWrapper.js @@ -60,7 +60,10 @@ function createHybridWrapper(func, bitmask, thisArg, partials, holders, partials length -= argsHolders.length; if (length < arity) { - return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length); + return createRecurryWrapper( + func, bitmask, createHybridWrapper, placeholder, thisArg, args, + argsHolders, argPos, ary, arity - length + ); } } var thisBinding = isBind ? thisArg : this, diff --git a/_createOver.js b/_createOver.js index c177d6f08..c24b36cfe 100644 --- a/_createOver.js +++ b/_createOver.js @@ -13,7 +13,7 @@ import rest from './rest'; */ function createOver(arrayFunc) { return rest(function(iteratees) { - iteratees = arrayMap(baseFlatten(iteratees), baseIteratee); + iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee); return rest(function(args) { var thisArg = this; return arrayFunc(iteratees, function(iteratee) { diff --git a/_createRecurryWrapper.js b/_createRecurryWrapper.js index 7a8d98a25..73e3b078d 100644 --- a/_createRecurryWrapper.js +++ b/_createRecurryWrapper.js @@ -40,9 +40,12 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par if (!(bitmask & CURRY_BOUND_FLAG)) { bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); } - var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity], - result = wrapFunc.apply(undefined, newData); + var newData = [ + func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, + newHoldersRight, newArgPos, ary, arity + ]; + var result = wrapFunc.apply(undefined, newData); if (isLaziable(func)) { setData(result, newData); } diff --git a/_createWrapper.js b/_createWrapper.js index 8db83b9ca..c15e68a4d 100644 --- a/_createWrapper.js +++ b/_createWrapper.js @@ -67,8 +67,12 @@ function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, a partials = holders = undefined; } - var data = isBindKey ? undefined : getData(func), - newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; + var data = isBindKey ? undefined : getData(func); + + var newData = [ + func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, + argPos, ary, arity + ]; if (data) { mergeData(newData, data); diff --git a/_hasPath.js b/_hasPath.js index aeaee998a..66d8fa9f1 100644 --- a/_hasPath.js +++ b/_hasPath.js @@ -1,4 +1,4 @@ -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import isArguments from './isArguments'; import isArray from './isArray'; import isIndex from './_isIndex'; @@ -23,7 +23,7 @@ function hasPath(object, path, hasFunc) { } var result = hasFunc(object, path); if (!result && !isKey(path)) { - path = baseToPath(path); + path = baseCastPath(path); object = parent(object, path); if (object != null) { path = last(path); diff --git a/_isKeyable.js b/_isKeyable.js index 972b86b62..c78cd2c74 100644 --- a/_isKeyable.js +++ b/_isKeyable.js @@ -8,7 +8,7 @@ function isKeyable(value) { var type = typeof value; return type == 'number' || type == 'boolean' || - (type == 'string' && value !== '__proto__') || value == null; + (type == 'string' && value != '__proto__') || value == null; } export default isKeyable; diff --git a/_lazyValue.js b/_lazyValue.js index b1dac437f..0fa97c62a 100644 --- a/_lazyValue.js +++ b/_lazyValue.js @@ -36,7 +36,8 @@ function lazyValue() { resIndex = 0, takeCount = nativeMin(length, this.__takeCount__); - if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) { + if (!isArr || arrLength < LARGE_ARRAY_SIZE || + (arrLength == length && takeCount == length)) { return baseWrapperValue(array, this.__actions__); } var result = []; diff --git a/_mapClear.js b/_mapClear.js index a805ef06d..8d27a8d68 100644 --- a/_mapClear.js +++ b/_mapClear.js @@ -9,7 +9,11 @@ import Map from './_Map'; * @memberOf MapCache */ function mapClear() { - this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash }; + this.__data__ = { + 'hash': new Hash, + 'map': Map ? new Map : [], + 'string': new Hash + }; } export default mapClear; diff --git a/_root.js b/_root.js index 85cf03fbe..8f97b7899 100644 --- a/_root.js +++ b/_root.js @@ -7,10 +7,14 @@ var objectTypes = { }; /** Detect free variable `exports`. */ -var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; +var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) + ? exports + : undefined; /** Detect free variable `module`. */ -var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null; +var freeModule = (objectTypes[typeof module] && module && !module.nodeType) + ? module + : undefined; /** Detect free variable `global` from Node.js. */ var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); @@ -30,6 +34,8 @@ var thisGlobal = checkGlobal(objectTypes[typeof this] && this); * 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 !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); +var root = freeGlobal || + ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || + freeSelf || thisGlobal || Function('return this')(); export default root; diff --git a/_toArrayLikeObject.js b/_toArrayLikeObject.js deleted file mode 100644 index 865fc5f52..000000000 --- a/_toArrayLikeObject.js +++ /dev/null @@ -1,14 +0,0 @@ -import isArrayLikeObject from './isArrayLikeObject'; - -/** - * Converts `value` to an array-like object if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Array} Returns the array-like object. - */ -function toArrayLikeObject(value) { - return isArrayLikeObject(value) ? value : []; -} - -export default toArrayLikeObject; diff --git a/_toFunction.js b/_toFunction.js deleted file mode 100644 index 0cddddc3d..000000000 --- a/_toFunction.js +++ /dev/null @@ -1,14 +0,0 @@ -import identity from './identity'; - -/** - * Converts `value` to a function if it's not one. - * - * @private - * @param {*} value The value to process. - * @returns {Function} Returns the function. - */ -function toFunction(value) { - return typeof value == 'function' ? value : identity; -} - -export default toFunction; diff --git a/array.default.js b/array.default.js index 06f864da7..15a60b909 100644 --- a/array.default.js +++ b/array.default.js @@ -13,6 +13,7 @@ import findIndex from './findIndex'; import findLastIndex from './findLastIndex'; import flatten from './flatten'; import flattenDeep from './flattenDeep'; +import flattenDepth from './flattenDepth'; import fromPairs from './fromPairs'; import head from './head'; import indexOf from './indexOf'; @@ -64,14 +65,14 @@ export default { chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, - fromPairs, head, indexOf, initial, intersection, - intersectionBy, intersectionWith, join, last, lastIndexOf, - pull, pullAll, pullAllBy, pullAt, remove, - reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, - sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, - tail, take, takeRight, takeRightWhile, takeWhile, - union, unionBy, unionWith, uniq, uniqBy, - uniqWith, unzip, unzipWith, without, xor, - xorBy, xorWith, zip, zipObject, zipObjectDeep, - zipWith + flattenDepth, fromPairs, head, indexOf, initial, + intersection, intersectionBy, intersectionWith, join, last, + lastIndexOf, pull, pullAll, pullAllBy, pullAt, + remove, reverse, slice, sortedIndex, sortedIndexBy, + sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, + sortedUniqBy, tail, take, takeRight, takeRightWhile, + takeWhile, union, unionBy, unionWith, uniq, + uniqBy, uniqWith, unzip, unzipWith, without, + xor, xorBy, xorWith, zip, zipObject, + zipObjectDeep, zipWith }; diff --git a/array.js b/array.js index 0e705fbfd..f6e6fb2a3 100644 --- a/array.js +++ b/array.js @@ -13,6 +13,7 @@ export { default as findIndex } from './findIndex'; export { default as findLastIndex } from './findLastIndex'; export { default as flatten } from './flatten'; export { default as flattenDeep } from './flattenDeep'; +export { default as flattenDepth } from './flattenDepth'; export { default as fromPairs } from './fromPairs'; export { default as head } from './head'; export { default as indexOf } from './indexOf'; diff --git a/at.js b/at.js index 9f8b4f087..988207df3 100644 --- a/at.js +++ b/at.js @@ -23,7 +23,7 @@ import rest from './rest'; * // => ['a', 'c'] */ var at = rest(function(object, paths) { - return baseAt(object, baseFlatten(paths)); + return baseAt(object, baseFlatten(paths, 1)); }); export default at; diff --git a/attempt.js b/attempt.js index 56cc0a9c6..70a4ecd26 100644 --- a/attempt.js +++ b/attempt.js @@ -1,5 +1,5 @@ import apply from './_apply'; -import isObject from './isObject'; +import isError from './isError'; import rest from './rest'; /** @@ -26,7 +26,7 @@ var attempt = rest(function(func, args) { try { return apply(func, undefined, args); } catch (e) { - return isObject(e) ? e : new Error(e); + return isError(e) ? e : new Error(e); } }); diff --git a/bindAll.js b/bindAll.js index 975dae922..0d189d90d 100644 --- a/bindAll.js +++ b/bindAll.js @@ -30,7 +30,7 @@ import rest from './rest'; * // => logs 'clicked docs' when clicked */ var bindAll = rest(function(object, methodNames) { - arrayEach(baseFlatten(methodNames), function(key) { + arrayEach(baseFlatten(methodNames, 1), function(key) { object[key] = bind(object[key], object); }); return object; diff --git a/castArray.js b/castArray.js new file mode 100644 index 000000000..68e47079f --- /dev/null +++ b/castArray.js @@ -0,0 +1,43 @@ +import isArray from './isArray'; + +/** + * Casts `value` as an array if it's not one. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. + * @example + * + * _.castArray(1); + * // => [1] + * + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] + * + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true + */ +function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray(value) ? value : [value]; +} + +export default castArray; diff --git a/concat.js b/concat.js index 0b71d10d7..aabe137f9 100644 --- a/concat.js +++ b/concat.js @@ -28,7 +28,7 @@ var concat = rest(function(array, values) { if (!isArray(array)) { array = array == null ? [] : [Object(array)]; } - values = baseFlatten(values); + values = baseFlatten(values, 1); return arrayConcat(array, values); }); diff --git a/debounce.js b/debounce.js index 539776d31..c7852128a 100644 --- a/debounce.js +++ b/debounce.js @@ -138,8 +138,10 @@ function debounce(func, wait, options) { if (!lastCalled && !maxTimeoutId && !leading) { lastCalled = stamp; } - var remaining = maxWait - (stamp - lastCalled), - isCalled = remaining <= 0 || remaining > maxWait; + var remaining = maxWait - (stamp - lastCalled); + + var isCalled = (remaining <= 0 || remaining > maxWait) && + (leading || maxTimeoutId); if (isCalled) { if (maxTimeoutId) { diff --git a/difference.js b/difference.js index 8691b4494..eb2e283d6 100644 --- a/difference.js +++ b/difference.js @@ -21,7 +21,7 @@ import rest from './rest'; */ var difference = rest(function(array, values) { return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, false, true)) + ? baseDifference(array, baseFlatten(values, 1, true)) : []; }); diff --git a/differenceBy.js b/differenceBy.js index dddbf9b33..cec8d0327 100644 --- a/differenceBy.js +++ b/differenceBy.js @@ -32,7 +32,7 @@ var differenceBy = rest(function(array, values) { iteratee = undefined; } return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee)) + ? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee)) : []; }); diff --git a/differenceWith.js b/differenceWith.js index 52956b0fd..e2f13959a 100644 --- a/differenceWith.js +++ b/differenceWith.js @@ -29,7 +29,7 @@ var differenceWith = rest(function(array, values) { comparator = undefined; } return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, false, true), undefined, comparator) + ? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator) : []; }); diff --git a/flatMap.js b/flatMap.js index 34959f609..8091faa78 100644 --- a/flatMap.js +++ b/flatMap.js @@ -22,7 +22,7 @@ import map from './map'; * // => [1, 1, 2, 2] */ function flatMap(collection, iteratee) { - return baseFlatten(map(collection, iteratee)); + return baseFlatten(map(collection, iteratee), 1); } export default flatMap; diff --git a/flatten.js b/flatten.js index 379f126e8..09f603bfb 100644 --- a/flatten.js +++ b/flatten.js @@ -1,7 +1,7 @@ import baseFlatten from './_baseFlatten'; /** - * Flattens `array` a single level. + * Flattens `array` a single level deep. * * @static * @memberOf _ @@ -10,12 +10,12 @@ import baseFlatten from './_baseFlatten'; * @returns {Array} Returns the new flattened array. * @example * - * _.flatten([1, [2, 3, [4]]]); - * // => [1, 2, 3, [4]] + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] */ function flatten(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array) : []; + return length ? baseFlatten(array, 1) : []; } export default flatten; diff --git a/flattenDeep.js b/flattenDeep.js index 782dc5281..1a9970e00 100644 --- a/flattenDeep.js +++ b/flattenDeep.js @@ -1,21 +1,24 @@ import baseFlatten from './_baseFlatten'; +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + /** - * This method is like `_.flatten` except that it recursively flattens `array`. + * Recursively flattens `array`. * * @static * @memberOf _ * @category Array - * @param {Array} array The array to recursively flatten. + * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. * @example * - * _.flattenDeep([1, [2, 3, [4]]]); - * // => [1, 2, 3, 4] + * _.flattenDeep([1, [2, [3, [4]], 5]]); + * // => [1, 2, 3, 4, 5] */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; + return length ? baseFlatten(array, INFINITY) : []; } export default flattenDeep; diff --git a/flattenDepth.js b/flattenDepth.js new file mode 100644 index 000000000..b658e33ba --- /dev/null +++ b/flattenDepth.js @@ -0,0 +1,32 @@ +import baseFlatten from './_baseFlatten'; +import toInteger from './toInteger'; + +/** + * Recursively flatten `array` up to `depth` times. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to flatten. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * var array = [1, [2, [3, [4]], 5]]; + * + * _.flattenDepth(array, 1); + * // => [1, 2, [3, [4]], 5] + * + * _.flattenDepth(array, 2); + * // => [1, 2, 3, [4], 5] + */ +function flattenDepth(array, depth) { + var length = array ? array.length : 0; + if (!length) { + return []; + } + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(array, depth); +} + +export default flattenDepth; diff --git a/forEach.js b/forEach.js index 30055ac45..6ecb13ba0 100644 --- a/forEach.js +++ b/forEach.js @@ -1,7 +1,7 @@ import arrayEach from './_arrayEach'; +import baseCastFunction from './_baseCastFunction'; import baseEach from './_baseEach'; import isArray from './isArray'; -import toFunction from './_toFunction'; /** * Iterates over elements of `collection` invoking `iteratee` for each element. @@ -34,7 +34,7 @@ import toFunction from './_toFunction'; function forEach(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEach(collection, iteratee) - : baseEach(collection, toFunction(iteratee)); + : baseEach(collection, baseCastFunction(iteratee)); } export default forEach; diff --git a/forEachRight.js b/forEachRight.js index 2f1ec34ba..66714170b 100644 --- a/forEachRight.js +++ b/forEachRight.js @@ -1,7 +1,7 @@ import arrayEachRight from './_arrayEachRight'; +import baseCastFunction from './_baseCastFunction'; import baseEachRight from './_baseEachRight'; import isArray from './isArray'; -import toFunction from './_toFunction'; /** * This method is like `_.forEach` except that it iterates over elements of @@ -24,7 +24,7 @@ import toFunction from './_toFunction'; function forEachRight(collection, iteratee) { return (typeof iteratee == 'function' && isArray(collection)) ? arrayEachRight(collection, iteratee) - : baseEachRight(collection, toFunction(iteratee)); + : baseEachRight(collection, baseCastFunction(iteratee)); } export default forEachRight; diff --git a/forIn.js b/forIn.js index 6ed3c1823..dba18f787 100644 --- a/forIn.js +++ b/forIn.js @@ -1,6 +1,6 @@ +import baseCastFunction from './_baseCastFunction'; import baseFor from './_baseFor'; import keysIn from './keysIn'; -import toFunction from './_toFunction'; /** * Iterates over own and inherited enumerable properties of an object invoking @@ -29,7 +29,9 @@ import toFunction from './_toFunction'; * // => logs 'a', 'b', then 'c' (iteration order is not guaranteed) */ function forIn(object, iteratee) { - return object == null ? object : baseFor(object, toFunction(iteratee), keysIn); + return object == null + ? object + : baseFor(object, baseCastFunction(iteratee), keysIn); } export default forIn; diff --git a/forInRight.js b/forInRight.js index 516ba43f8..e512dd1f6 100644 --- a/forInRight.js +++ b/forInRight.js @@ -1,6 +1,6 @@ +import baseCastFunction from './_baseCastFunction'; import baseForRight from './_baseForRight'; import keysIn from './keysIn'; -import toFunction from './_toFunction'; /** * This method is like `_.forIn` except that it iterates over properties of @@ -27,7 +27,9 @@ import toFunction from './_toFunction'; * // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' */ function forInRight(object, iteratee) { - return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn); + return object == null + ? object + : baseForRight(object, baseCastFunction(iteratee), keysIn); } export default forInRight; diff --git a/forOwn.js b/forOwn.js index 294ac1c9e..e849d367b 100644 --- a/forOwn.js +++ b/forOwn.js @@ -1,5 +1,5 @@ +import baseCastFunction from './_baseCastFunction'; import baseForOwn from './_baseForOwn'; -import toFunction from './_toFunction'; /** * Iterates over own enumerable properties of an object invoking `iteratee` @@ -28,7 +28,7 @@ import toFunction from './_toFunction'; * // => logs 'a' then 'b' (iteration order is not guaranteed) */ function forOwn(object, iteratee) { - return object && baseForOwn(object, toFunction(iteratee)); + return object && baseForOwn(object, baseCastFunction(iteratee)); } export default forOwn; diff --git a/forOwnRight.js b/forOwnRight.js index 504859a28..825125d2c 100644 --- a/forOwnRight.js +++ b/forOwnRight.js @@ -1,5 +1,5 @@ +import baseCastFunction from './_baseCastFunction'; import baseForOwnRight from './_baseForOwnRight'; -import toFunction from './_toFunction'; /** * This method is like `_.forOwn` except that it iterates over properties of @@ -26,7 +26,7 @@ import toFunction from './_toFunction'; * // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b' */ function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, toFunction(iteratee)); + return object && baseForOwnRight(object, baseCastFunction(iteratee)); } export default forOwnRight; diff --git a/intersection.js b/intersection.js index 4de5a206e..60b3a0913 100644 --- a/intersection.js +++ b/intersection.js @@ -1,7 +1,7 @@ import arrayMap from './_arrayMap'; +import baseCastArrayLikeObject from './_baseCastArrayLikeObject'; import baseIntersection from './_baseIntersection'; import rest from './rest'; -import toArrayLikeObject from './_toArrayLikeObject'; /** * Creates an array of unique values that are included in all given arrays @@ -19,7 +19,7 @@ import toArrayLikeObject from './_toArrayLikeObject'; * // => [2] */ var intersection = rest(function(arrays) { - var mapped = arrayMap(arrays, toArrayLikeObject); + var mapped = arrayMap(arrays, baseCastArrayLikeObject); return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped) : []; diff --git a/intersectionBy.js b/intersectionBy.js index af686e4b7..880668abb 100644 --- a/intersectionBy.js +++ b/intersectionBy.js @@ -1,9 +1,9 @@ import arrayMap from './_arrayMap'; +import baseCastArrayLikeObject from './_baseCastArrayLikeObject'; import baseIntersection from './_baseIntersection'; import baseIteratee from './_baseIteratee'; import last from './last'; import rest from './rest'; -import toArrayLikeObject from './_toArrayLikeObject'; /** * This method is like `_.intersection` except that it accepts `iteratee` @@ -27,7 +27,7 @@ import toArrayLikeObject from './_toArrayLikeObject'; */ var intersectionBy = rest(function(arrays) { var iteratee = last(arrays), - mapped = arrayMap(arrays, toArrayLikeObject); + mapped = arrayMap(arrays, baseCastArrayLikeObject); if (iteratee === last(mapped)) { iteratee = undefined; diff --git a/intersectionWith.js b/intersectionWith.js index 4dc7a6766..59d5ff1ac 100644 --- a/intersectionWith.js +++ b/intersectionWith.js @@ -1,8 +1,8 @@ import arrayMap from './_arrayMap'; +import baseCastArrayLikeObject from './_baseCastArrayLikeObject'; import baseIntersection from './_baseIntersection'; import last from './last'; import rest from './rest'; -import toArrayLikeObject from './_toArrayLikeObject'; /** * This method is like `_.intersection` except that it accepts `comparator` @@ -25,7 +25,7 @@ import toArrayLikeObject from './_toArrayLikeObject'; */ var intersectionWith = rest(function(arrays) { var comparator = last(arrays), - mapped = arrayMap(arrays, toArrayLikeObject); + mapped = arrayMap(arrays, baseCastArrayLikeObject); if (comparator === last(mapped)) { comparator = undefined; diff --git a/isArray.js b/isArray.js index 8c1d036f2..2657ccc2c 100644 --- a/isArray.js +++ b/isArray.js @@ -3,7 +3,7 @@ * * @static * @memberOf _ - * @type Function + * @type {Function} * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. diff --git a/isArrayBuffer.js b/isArrayBuffer.js index 4bbfe8e4f..9201e9445 100644 --- a/isArrayBuffer.js +++ b/isArrayBuffer.js @@ -16,7 +16,6 @@ var objectToString = objectProto.toString; * * @static * @memberOf _ - * @type Function * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. diff --git a/isArrayLike.js b/isArrayLike.js index 981e18600..cf64b36d8 100644 --- a/isArrayLike.js +++ b/isArrayLike.js @@ -9,7 +9,6 @@ import isLength from './isLength'; * * @static * @memberOf _ - * @type Function * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. diff --git a/isArrayLikeObject.js b/isArrayLikeObject.js index c73838a38..991ef40e2 100644 --- a/isArrayLikeObject.js +++ b/isArrayLikeObject.js @@ -7,7 +7,6 @@ import isObjectLike from './isObjectLike'; * * @static * @memberOf _ - * @type Function * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. diff --git a/isBuffer.js b/isBuffer.js index d092a94f2..bfccb20e3 100644 --- a/isBuffer.js +++ b/isBuffer.js @@ -8,13 +8,19 @@ var objectTypes = { }; /** Detect free variable `exports`. */ -var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; +var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) + ? exports + : undefined; /** Detect free variable `module`. */ -var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null; +var freeModule = (objectTypes[typeof module] && module && !module.nodeType) + ? module + : undefined; /** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; +var moduleExports = (freeModule && freeModule.exports === freeExports) + ? freeExports + : undefined; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; diff --git a/isEmpty.js b/isEmpty.js index 64f348e28..b12758a1c 100644 --- a/isEmpty.js +++ b/isEmpty.js @@ -39,7 +39,8 @@ var hasOwnProperty = objectProto.hasOwnProperty; */ function isEmpty(value) { if (isArrayLike(value) && - (isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) { + (isArray(value) || isString(value) || + isFunction(value.splice) || isArguments(value))) { return !value.length; } for (var key in value) { diff --git a/isEqualWith.js b/isEqualWith.js index 0518f08ff..d4d3da7fe 100644 --- a/isEqualWith.js +++ b/isEqualWith.js @@ -1,10 +1,10 @@ import baseIsEqual from './_baseIsEqual'; /** - * This method is like `_.isEqual` except that it accepts `customizer` which is - * invoked to compare values. If `customizer` returns `undefined` comparisons are - * handled by the method instead. The `customizer` is invoked with up to six arguments: - * (objValue, othValue [, index|key, object, other, stack]). + * This method is like `_.isEqual` except that it accepts `customizer` which + * is invoked to compare values. If `customizer` returns `undefined` comparisons + * are handled by the method instead. The `customizer` is invoked with up to + * six arguments: (objValue, othValue [, index|key, object, other, stack]). * * @static * @memberOf _ diff --git a/isError.js b/isError.js index 6ec72aac8..01565170c 100644 --- a/isError.js +++ b/isError.js @@ -30,8 +30,12 @@ var objectToString = objectProto.toString; * // => false */ function isError(value) { - return isObjectLike(value) && - typeof value.message == 'string' && objectToString.call(value) == errorTag; + if (!isObjectLike(value)) { + return false; + } + var Ctor = value.constructor; + return (objectToString.call(value) == errorTag) || + (typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag); } export default isError; diff --git a/isLength.js b/isLength.js index d13d42318..6dd6cc5ec 100644 --- a/isLength.js +++ b/isLength.js @@ -26,7 +26,8 @@ var MAX_SAFE_INTEGER = 9007199254740991; * // => false */ function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } export default isLength; diff --git a/isMatch.js b/isMatch.js index c49669a93..14186f601 100644 --- a/isMatch.js +++ b/isMatch.js @@ -2,8 +2,9 @@ import baseIsMatch from './_baseIsMatch'; import getMatchData from './_getMatchData'; /** - * Performs a deep comparison between `object` and `source` to determine if - * `object` contains equivalent property values. + * 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. * * **Note:** This method supports comparing the same values as `_.isEqual`. * diff --git a/isPlainObject.js b/isPlainObject.js index 2b15908a5..8e11c789e 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -50,7 +50,8 @@ var getPrototypeOf = Object.getPrototypeOf; * // => true */ function isPlainObject(value) { - if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { + if (!isObjectLike(value) || + objectToString.call(value) != objectTag || isHostObject(value)) { return false; } var proto = objectProto; diff --git a/isTypedArray.js b/isTypedArray.js index e1f9e5481..e96f32e20 100644 --- a/isTypedArray.js +++ b/isTypedArray.js @@ -68,7 +68,8 @@ var objectToString = objectProto.toString; * // => false */ function isTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; } export default isTypedArray; diff --git a/iteratee.js b/iteratee.js index 56344d7cf..2e791fc70 100644 --- a/iteratee.js +++ b/iteratee.js @@ -5,7 +5,8 @@ import baseIteratee from './_baseIteratee'; * Creates a function that invokes `func` with the arguments of the created * function. If `func` is a property name the created callback returns the * property value for a given element. If `func` is an object the created - * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`. + * callback returns `true` for elements that contain the equivalent object + * properties, otherwise it returns `false`. * * @static * @memberOf _ diff --git a/lang.default.js b/lang.default.js index b76e7b81e..f56c00e73 100644 --- a/lang.default.js +++ b/lang.default.js @@ -1,3 +1,4 @@ +import castArray from './castArray'; import clone from './clone'; import cloneDeep from './cloneDeep'; import cloneDeepWith from './cloneDeepWith'; @@ -53,15 +54,15 @@ import toSafeInteger from './toSafeInteger'; import toString from './toString'; export default { - clone, cloneDeep, cloneDeepWith, cloneWith, eq, - gt, gte, isArguments, isArray, isArrayBuffer, - isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, - isElement, isEmpty, isEqual, isEqualWith, isError, - isFinite, isFunction, isInteger, isLength, isMap, - isMatch, isMatchWith, isNaN, isNative, isNil, - isNull, isNumber, isObject, isObjectLike, isPlainObject, - isRegExp, isSafeInteger, isSet, isString, isSymbol, - isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, - lte, toArray, toInteger, toLength, toNumber, - toPlainObject, toSafeInteger, toString + castArray, clone, cloneDeep, cloneDeepWith, cloneWith, + eq, gt, gte, isArguments, isArray, + isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, + isDate, isElement, isEmpty, isEqual, isEqualWith, + isError, isFinite, isFunction, isInteger, isLength, + isMap, isMatch, isMatchWith, isNaN, isNative, + isNil, isNull, isNumber, isObject, isObjectLike, + isPlainObject, isRegExp, isSafeInteger, isSet, isString, + isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, + lt, lte, toArray, toInteger, toLength, + toNumber, toPlainObject, toSafeInteger, toString }; diff --git a/lang.js b/lang.js index 2fb3db6d9..4d7b42def 100644 --- a/lang.js +++ b/lang.js @@ -1,3 +1,4 @@ +export { default as castArray } from './castArray'; export { default as clone } from './clone'; export { default as cloneDeep } from './cloneDeep'; export { default as cloneDeepWith } from './cloneDeepWith'; diff --git a/lodash.default.js b/lodash.default.js index a8ca95744..e227fc796 100644 --- a/lodash.default.js +++ b/lodash.default.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.3.0 (Custom Build) + * lodash 4.4.0 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -44,7 +44,7 @@ import toInteger from './toInteger'; import lodash from './wrapperLodash'; /** Used as the semantic version number. */ -var VERSION = '4.3.0'; +var VERSION = '4.4.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_KEY_FLAG = 2; @@ -100,6 +100,7 @@ lodash.before = func.before; lodash.bind = func.bind; lodash.bindAll = util.bindAll; lodash.bindKey = func.bindKey; +lodash.castArray = lang.castArray; lodash.chain = seq.chain; lodash.chunk = array.chunk; lodash.compact = array.compact; @@ -128,6 +129,7 @@ lodash.filter = collection.filter; lodash.flatMap = collection.flatMap; lodash.flatten = array.flatten; lodash.flattenDeep = array.flattenDeep; +lodash.flattenDepth = array.flattenDepth; lodash.flip = func.flip; lodash.flow = util.flow; lodash.flowRight = util.flowRight; @@ -396,7 +398,7 @@ mixin(lodash, (function() { * * @static * @memberOf _ - * @type string + * @type {string} */ lodash.VERSION = VERSION; (lodash.templateSettings = string.templateSettings).imports._ = lodash; @@ -419,7 +421,10 @@ arrayEach(['drop', 'take'], function(methodName, index) { if (filtered) { result.__takeCount__ = nativeMin(n, result.__takeCount__); } else { - result.__views__.push({ 'size': nativeMin(n, MAX_ARRAY_LENGTH), 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') }); + result.__views__.push({ + 'size': nativeMin(n, MAX_ARRAY_LENGTH), + 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') + }); } return result; }; @@ -436,7 +441,10 @@ arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { LazyWrapper.prototype[methodName] = function(iteratee) { var result = this.clone(); - result.__iteratees__.push({ 'iteratee': baseIteratee(iteratee, 3), 'type': type }); + result.__iteratees__.push({ + 'iteratee': baseIteratee(iteratee, 3), + 'type': type + }); result.__filtered__ = result.__filtered__ || isFilter; return result; }; @@ -588,7 +596,10 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) { } }); -realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }]; +realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ + 'name': 'wrapper', + 'func': undefined +}]; // Add functions to the lazy wrapper. LazyWrapper.prototype.clone = lazyClone; diff --git a/lodash.js b/lodash.js index 36ead17df..746fab809 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.3.0 (Custom Build) + * lodash 4.4.0 (Custom Build) * Build: `lodash modularize exports="es" -o ./` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -22,6 +22,7 @@ export { default as bindAll } from './bindAll'; export { default as bindKey } from './bindKey'; export { default as camelCase } from './camelCase'; export { default as capitalize } from './capitalize'; +export { default as castArray } from './castArray'; export { default as ceil } from './ceil'; export { default as chain } from './chain'; export { default as chunk } from './chunk'; @@ -73,6 +74,7 @@ export { default as findLastKey } from './findLastKey'; export { default as flatMap } from './flatMap'; export { default as flatten } from './flatten'; export { default as flattenDeep } from './flattenDeep'; +export { default as flattenDepth } from './flattenDepth'; export { default as flip } from './flip'; export { default as floor } from './floor'; export { default as flow } from './flow'; diff --git a/matches.js b/matches.js index f8c3cd2da..1e4e9bcbb 100644 --- a/matches.js +++ b/matches.js @@ -2,9 +2,10 @@ import baseClone from './_baseClone'; import baseMatches from './_baseMatches'; /** - * Creates a function that performs a deep partial comparison between a given + * 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`. + * property values, else `false`. The created function is equivalent to + * `_.isMatch` with a `source` partially applied. * * **Note:** This method supports comparing the same values as `_.isEqual`. * diff --git a/matchesProperty.js b/matchesProperty.js index 52d24ec41..4a8c3d6e4 100644 --- a/matchesProperty.js +++ b/matchesProperty.js @@ -2,7 +2,7 @@ import baseClone from './_baseClone'; import baseMatchesProperty from './_baseMatchesProperty'; /** - * Creates a function that performs a deep partial comparison between the + * Creates a function that performs a partial deep comparison between the * value at `path` of a given object to `srcValue`, returning `true` if the * object value is equivalent, else `false`. * diff --git a/merge.js b/merge.js index 85cc86409..a00334f92 100644 --- a/merge.js +++ b/merge.js @@ -2,12 +2,12 @@ import baseMerge from './_baseMerge'; import createAssigner from './_createAssigner'; /** - * Recursively merges own and inherited enumerable properties of source - * objects into the destination object, skipping source properties that resolve - * to `undefined`. Array and plain object properties are merged recursively. - * Other objects and value types are overridden by assignment. Source objects - * are applied from left to right. Subsequent sources overwrite property - * assignments of previous sources. + * Recursively merges own and inherited enumerable properties of source objects + * into the destination object. Source properties that resolve to `undefined` + * are skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object`. * diff --git a/now.js b/now.js index 8480fdf46..2a751946f 100644 --- a/now.js +++ b/now.js @@ -4,7 +4,7 @@ * * @static * @memberOf _ - * @type Function + * @type {Function} * @category Date * @returns {number} Returns the timestamp. * @example diff --git a/omit.js b/omit.js index c073d0bd3..3b5b2fedc 100644 --- a/omit.js +++ b/omit.js @@ -14,7 +14,7 @@ import rest from './rest'; * @category Object * @param {Object} object The source object. * @param {...(string|string[])} [props] The property names to omit, specified - * individually or in arrays.. + * individually or in arrays. * @returns {Object} Returns the new object. * @example * @@ -27,7 +27,7 @@ var omit = rest(function(object, props) { if (object == null) { return {}; } - props = arrayMap(baseFlatten(props), String); + props = arrayMap(baseFlatten(props, 1), String); return basePick(object, baseDifference(keysIn(object), props)); }); diff --git a/overArgs.js b/overArgs.js index fde6c73c3..53a8ae3ca 100644 --- a/overArgs.js +++ b/overArgs.js @@ -39,7 +39,7 @@ var nativeMin = Math.min; * // => [100, 10] */ var overArgs = rest(function(func, transforms) { - transforms = arrayMap(baseFlatten(transforms), baseIteratee); + transforms = arrayMap(baseFlatten(transforms, 1), baseIteratee); var funcsLength = transforms.length; return rest(function(args) { diff --git a/package.json b/package.json index a1baa7ff8..1bd256807 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-es", - "version": "4.3.0", + "version": "4.4.0", "description": "Lodash exported as ES modules.", "homepage": "https://lodash.com/custom-builds", "license": "MIT", diff --git a/parseInt.js b/parseInt.js index f99099a56..5019e2c99 100644 --- a/parseInt.js +++ b/parseInt.js @@ -22,7 +22,7 @@ var nativeParseInt = root.parseInt; * @memberOf _ * @category String * @param {string} string The string to convert. - * @param {number} [radix] The radix to interpret `value` by. + * @param {number} [radix=10] The radix to interpret `value` by. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {number} Returns the converted integer. * @example diff --git a/pick.js b/pick.js index 9be4baf7c..7399ccbf1 100644 --- a/pick.js +++ b/pick.js @@ -20,7 +20,7 @@ import rest from './rest'; * // => { 'a': 1, 'c': 3 } */ var pick = rest(function(object, props) { - return object == null ? {} : basePick(object, baseFlatten(props)); + return object == null ? {} : basePick(object, baseFlatten(props, 1)); }); export default pick; diff --git a/pullAt.js b/pullAt.js index 28f1eb679..6b7fca7b8 100644 --- a/pullAt.js +++ b/pullAt.js @@ -30,7 +30,7 @@ import rest from './rest'; * // => [10, 20] */ var pullAt = rest(function(array, indexes) { - indexes = arrayMap(baseFlatten(indexes), String); + indexes = arrayMap(baseFlatten(indexes, 1), String); var result = baseAt(array, indexes); basePullAt(array, indexes.sort(compareAscending)); diff --git a/rearg.js b/rearg.js index 720f05c9f..2724fe7d4 100644 --- a/rearg.js +++ b/rearg.js @@ -28,7 +28,7 @@ var REARG_FLAG = 256; * // => ['a', 'b', 'c'] */ var rearg = rest(function(func, indexes) { - return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); + return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1)); }); export default rearg; diff --git a/result.js b/result.js index 1e21a7e35..b53e79f09 100644 --- a/result.js +++ b/result.js @@ -1,4 +1,4 @@ -import baseToPath from './_baseToPath'; +import baseCastPath from './_baseCastPath'; import get from './get'; import isFunction from './isFunction'; import isKey from './_isKey'; @@ -34,7 +34,7 @@ import parent from './_parent'; */ function result(object, path, defaultValue) { if (!isKey(path, object)) { - path = baseToPath(path); + path = baseCastPath(path); var result = get(object, path); object = parent(object, path); } else { diff --git a/sortBy.js b/sortBy.js index 09b9e4374..2008cbf51 100644 --- a/sortBy.js +++ b/sortBy.js @@ -46,7 +46,7 @@ var sortBy = rest(function(collection, iteratees) { } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { iteratees.length = 1; } - return baseOrderBy(collection, baseFlatten(iteratees), []); + return baseOrderBy(collection, baseFlatten(iteratees, 1), []); }); export default sortBy; diff --git a/template.js b/template.js index 2bc780322..e9880070b 100644 --- a/template.js +++ b/template.js @@ -210,7 +210,8 @@ function template(string, options, guard) { 'return __p\n}'; var result = attempt(function() { - return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues); + return Function(importsKeys, sourceURL + 'return ' + source) + .apply(undefined, importsValues); }); // Provide the compiled function's source by its `toString` method or diff --git a/templateSettings.js b/templateSettings.js index c614525a4..b310bdbda 100644 --- a/templateSettings.js +++ b/templateSettings.js @@ -10,7 +10,7 @@ import reInterpolate from './_reInterpolate'; * * @static * @memberOf _ - * @type Object + * @type {Object} */ var templateSettings = { @@ -18,7 +18,7 @@ var templateSettings = { * Used to detect `data` property values to be HTML-escaped. * * @memberOf _.templateSettings - * @type RegExp + * @type {RegExp} */ 'escape': reEscape, @@ -26,7 +26,7 @@ var templateSettings = { * Used to detect code to be evaluated. * * @memberOf _.templateSettings - * @type RegExp + * @type {RegExp} */ 'evaluate': reEvaluate, @@ -34,7 +34,7 @@ var templateSettings = { * Used to detect `data` property values to inject. * * @memberOf _.templateSettings - * @type RegExp + * @type {RegExp} */ 'interpolate': reInterpolate, @@ -42,7 +42,7 @@ var templateSettings = { * Used to reference the data object in the template text. * * @memberOf _.templateSettings - * @type string + * @type {string} */ 'variable': '', @@ -50,7 +50,7 @@ var templateSettings = { * Used to import variables into the compiled template. * * @memberOf _.templateSettings - * @type Object + * @type {Object} */ 'imports': { @@ -58,7 +58,7 @@ var templateSettings = { * A reference to the `lodash` function. * * @memberOf _.templateSettings.imports - * @type Function + * @type {Function} */ '_': { 'escape': escape } } diff --git a/throttle.js b/throttle.js index 93b4aeca3..a5285a1c0 100644 --- a/throttle.js +++ b/throttle.js @@ -55,7 +55,11 @@ function throttle(func, wait, options) { leading = 'leading' in options ? !!options.leading : leading; trailing = 'trailing' in options ? !!options.trailing : trailing; } - return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing }); + return debounce(func, wait, { + 'leading': leading, + 'maxWait': wait, + 'trailing': trailing + }); } export default throttle; diff --git a/times.js b/times.js index 30b4503e1..efdcfb016 100644 --- a/times.js +++ b/times.js @@ -1,5 +1,5 @@ +import baseCastFunction from './_baseCastFunction'; import baseTimes from './_baseTimes'; -import toFunction from './_toFunction'; import toInteger from './toInteger'; /** Used as references for various `Number` constants. */ @@ -37,7 +37,7 @@ function times(n, iteratee) { var index = MAX_ARRAY_LENGTH, length = nativeMin(n, MAX_ARRAY_LENGTH); - iteratee = toFunction(iteratee); + iteratee = baseCastFunction(iteratee); n -= MAX_ARRAY_LENGTH; var result = baseTimes(length, iteratee); diff --git a/toPairs.js b/toPairs.js index 4a411e1fc..0ee750ecc 100644 --- a/toPairs.js +++ b/toPairs.js @@ -2,7 +2,8 @@ import baseToPairs from './_baseToPairs'; import keys from './keys'; /** - * Creates an array of own enumerable key-value pairs for `object`. + * Creates an array of own enumerable key-value pairs for `object` which + * can be consumed by `_.fromPairs`. * * @static * @memberOf _ diff --git a/toPairsIn.js b/toPairsIn.js index 950f14b85..f8f1ac189 100644 --- a/toPairsIn.js +++ b/toPairsIn.js @@ -2,7 +2,8 @@ import baseToPairs from './_baseToPairs'; import keysIn from './keysIn'; /** - * Creates an array of own and inherited enumerable key-value pairs for `object`. + * Creates an array of own and inherited enumerable key-value pairs for + * `object` which can be consumed by `_.fromPairs`. * * @static * @memberOf _ diff --git a/trim.js b/trim.js index 76c8adc3d..f70895b06 100644 --- a/trim.js +++ b/trim.js @@ -42,7 +42,9 @@ function trim(string, chars, guard) { var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars); - return strSymbols.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1).join(''); + return strSymbols + .slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1) + .join(''); } export default trim; diff --git a/trimEnd.js b/trimEnd.js index fbde7f963..ab2d1f3f2 100644 --- a/trimEnd.js +++ b/trimEnd.js @@ -36,7 +36,9 @@ function trimEnd(string, chars, guard) { return string; } var strSymbols = stringToArray(string); - return strSymbols.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1).join(''); + return strSymbols + .slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1) + .join(''); } export default trimEnd; diff --git a/trimStart.js b/trimStart.js index efd13c605..7f40935f9 100644 --- a/trimStart.js +++ b/trimStart.js @@ -36,7 +36,9 @@ function trimStart(string, chars, guard) { return string; } var strSymbols = stringToArray(string); - return strSymbols.slice(charsStartIndex(strSymbols, stringToArray(chars))).join(''); + return strSymbols + .slice(charsStartIndex(strSymbols, stringToArray(chars))) + .join(''); } export default trimStart; diff --git a/truncate.js b/truncate.js index 0da2a02c6..9e4c689fd 100644 --- a/truncate.js +++ b/truncate.js @@ -33,7 +33,7 @@ var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange * @memberOf _ * @category String * @param {string} [string=''] The string to truncate. - * @param {Object} [options] The options object. + * @param {Object} [options=({})] The options object. * @param {number} [options.length=30] The maximum string length. * @param {string} [options.omission='...'] The string to indicate text is omitted. * @param {RegExp|string} [options.separator] The separator pattern to truncate to. diff --git a/union.js b/union.js index 6d7a7ed84..bc3d5e70d 100644 --- a/union.js +++ b/union.js @@ -18,7 +18,7 @@ import rest from './rest'; * // => [2, 1, 4] */ var union = rest(function(arrays) { - return baseUniq(baseFlatten(arrays, false, true)); + return baseUniq(baseFlatten(arrays, 1, true)); }); export default union; diff --git a/unionBy.js b/unionBy.js index fa6644eb2..bd547cddd 100644 --- a/unionBy.js +++ b/unionBy.js @@ -30,7 +30,7 @@ var unionBy = rest(function(arrays) { if (isArrayLikeObject(iteratee)) { iteratee = undefined; } - return baseUniq(baseFlatten(arrays, false, true), baseIteratee(iteratee)); + return baseUniq(baseFlatten(arrays, 1, true), baseIteratee(iteratee)); }); export default unionBy; diff --git a/unionWith.js b/unionWith.js index ff6e45a12..4bf011dfc 100644 --- a/unionWith.js +++ b/unionWith.js @@ -28,7 +28,7 @@ var unionWith = rest(function(arrays) { if (isArrayLikeObject(comparator)) { comparator = undefined; } - return baseUniq(baseFlatten(arrays, false, true), undefined, comparator); + return baseUniq(baseFlatten(arrays, 1, true), undefined, comparator); }); export default unionWith; diff --git a/uniqueId.js b/uniqueId.js index 71fd2cfe4..7ae814e5e 100644 --- a/uniqueId.js +++ b/uniqueId.js @@ -9,7 +9,7 @@ var idCounter = 0; * @static * @memberOf _ * @category Util - * @param {string} [prefix] The value to prefix the ID with. + * @param {string} [prefix=''] The value to prefix the ID with. * @returns {string} Returns the unique ID. * @example * diff --git a/valuesIn.js b/valuesIn.js index db4442246..3fa3a96f2 100644 --- a/valuesIn.js +++ b/valuesIn.js @@ -24,7 +24,7 @@ import keysIn from './keysIn'; * // => [1, 2, 3] (iteration order is not guaranteed) */ function valuesIn(object) { - return object == null ? baseValues(object, keysIn(object)) : []; + return object == null ? [] : baseValues(object, keysIn(object)); } export default valuesIn; diff --git a/wrap.js b/wrap.js index 317ba6cbb..397f64fb2 100644 --- a/wrap.js +++ b/wrap.js @@ -11,7 +11,7 @@ import partial from './partial'; * @memberOf _ * @category Function * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. + * @param {Function} [wrapper=identity] The wrapper function. * @returns {Function} Returns the new function. * @example * diff --git a/wrapperAt.js b/wrapperAt.js index 5e47385bc..0ff082544 100644 --- a/wrapperAt.js +++ b/wrapperAt.js @@ -26,17 +26,22 @@ import thru from './thru'; * // => ['a', 'c'] */ var wrapperAt = rest(function(paths) { - paths = baseFlatten(paths); + paths = baseFlatten(paths, 1); var length = paths.length, start = length ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) { return baseAt(object, paths); }; - if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) { + if (length > 1 || this.__actions__.length || + !(value instanceof LazyWrapper) || !isIndex(start)) { return this.thru(interceptor); } value = value.slice(start, +start + (length ? 1 : 0)); - value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); + value.__actions__.push({ + 'func': thru, + 'args': [interceptor], + 'thisArg': undefined + }); return new LodashWrapper(value, this.__chain__).thru(function(array) { if (length && !array.length) { array.push(undefined); diff --git a/wrapperLodash.js b/wrapperLodash.js index 1d8438612..13109783e 100644 --- a/wrapperLodash.js +++ b/wrapperLodash.js @@ -50,28 +50,28 @@ var hasOwnProperty = objectProto.hasOwnProperty; * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` * * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, - * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, - * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, - * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, - * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, - * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, - * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, - * `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, - * `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, - * `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, - * `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`, - * `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`, - * `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`, - * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, - * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, - * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, - * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, - * `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, - * `zipObjectDeep`, and `zipWith` + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`, + * `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`, + * `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`, + * `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, + * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`, + * `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`, + * `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`, + * `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`, + * `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, + * `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, + * `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, + * `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`, + * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`, + * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`, + * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, + * `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, diff --git a/wrapperReverse.js b/wrapperReverse.js index 86306a99b..c53c5919b 100644 --- a/wrapperReverse.js +++ b/wrapperReverse.js @@ -30,7 +30,11 @@ function wrapperReverse() { wrapped = new LazyWrapper(this); } wrapped = wrapped.reverse(); - wrapped.__actions__.push({ 'func': thru, 'args': [reverse], 'thisArg': undefined }); + wrapped.__actions__.push({ + 'func': thru, + 'args': [reverse], + 'thisArg': undefined + }); return new LodashWrapper(wrapped, this.__chain__); } return this.thru(reverse);