diff options
Diffstat (limited to 'deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js')
-rw-r--r-- | deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js b/deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js index cf05fe5f1a5..0daaa016227 100644 --- a/deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js +++ b/deps/npm/node_modules/lodash.union/node_modules/lodash._baseflatten/index.js @@ -1,10 +1,10 @@ /** - * lodash 4.1.1 (Custom Build) <https://lodash.com/> + * lodash 4.2.0 (Custom Build) <https://lodash.com/> * Build: `lodash modularize exports="npm" -o ./` - * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> + * Copyright jQuery Foundation and other contributors <https://jquery.org/> + * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> - * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license <https://lodash.com/license> + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ /** Used as references for various `Number` constants. */ @@ -41,7 +41,8 @@ var objectProto = Object.prototype; var hasOwnProperty = objectProto.hasOwnProperty; /** - * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -55,23 +56,24 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable; * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. - * @param {boolean} [isStrict] Restrict flattening to arrays-like objects. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ -function baseFlatten(array, depth, isStrict, result) { - result || (result = []); - +function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; + predicate || (predicate = isFlattenable); + result || (result = []); + while (++index < length) { var value = array[index]; - if (depth > 0 && isArrayLikeObject(value) && - (isStrict || isArray(value) || isArguments(value))) { + if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, isStrict, result); + baseFlatten(value, depth - 1, predicate, isStrict, result); } else { arrayPush(result, value); } @@ -98,8 +100,9 @@ function baseProperty(key) { /** * Gets the "length" property value of `object`. * - * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) - * that affects Safari on at least iOS 8.1-8.3 ARM64. + * **Note:** This function is used to avoid a + * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects + * Safari on at least iOS 8.1-8.3 ARM64. * * @private * @param {Object} object The object to query. @@ -108,13 +111,26 @@ function baseProperty(key) { var getLength = baseProperty('length'); /** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArrayLikeObject(value) && (isArray(value) || isArguments(value)); +} + +/** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArguments(function() { return arguments; }()); @@ -134,10 +150,12 @@ function isArguments(value) { * * @static * @memberOf _ + * @since 0.1.0 * @type {Function} * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isArray([1, 2, 3]); @@ -161,6 +179,7 @@ var isArray = Array.isArray; * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. @@ -188,9 +207,11 @@ function isArrayLike(value) { * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); @@ -214,9 +235,11 @@ function isArrayLikeObject(value) { * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @returns {boolean} Returns `true` if `value` is correctly classified, + * else `false`. * @example * * _.isFunction(_); @@ -236,13 +259,16 @@ function isFunction(value) { /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This function is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, + * else `false`. * @example * * _.isLength(3); @@ -263,11 +289,13 @@ function isLength(value) { } /** - * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static * @memberOf _ + * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. @@ -296,6 +324,7 @@ function isObject(value) { * * @static * @memberOf _ + * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. |