MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / baseFlatten

Function baseFlatten

MathBox/mathbox-bundle.js:36145–36172  ·  view source on GitHub ↗

* The base implementation of `_.flatten` without support for callback * shorthands or `thisArg` binding. * * @private * @param {Array} array The array to flatten. * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. * @param {boolean} [i

(array, isShallow, isStrict, fromIndex)

Source from the content-addressed store, hash-verified

36143 * @returns {Array} Returns a new flattened array.
36144 */
36145 function baseFlatten(array, isShallow, isStrict, fromIndex) {
36146 var index = (fromIndex || 0) - 1,
36147 length = array ? array.length : 0,
36148 result = [];
36149
36150 while (++index < length) {
36151 var value = array[index];
36152
36153 if (value && typeof value == 'object' && typeof value.length == 'number'
36154 && (isArray(value) || isArguments(value))) {
36155 // recursively flatten arrays (susceptible to call stack limits)
36156 if (!isShallow) {
36157 value = baseFlatten(value, isShallow, isStrict);
36158 }
36159 var valIndex = -1,
36160 valLength = value.length,
36161 resIndex = result.length;
36162
36163 result.length += valLength;
36164 while (++valIndex < valLength) {
36165 result[resIndex++] = value[valIndex];
36166 }
36167 } else if (!isStrict) {
36168 result.push(value);
36169 }
36170 }
36171 return result;
36172 }
36173
36174 /**
36175 * The base implementation of `_.isEqual`, without support for `thisArg` binding,

Callers 7

omitFunction · 0.85
pickFunction · 0.85
atFunction · 0.85
differenceFunction · 0.85
flattenFunction · 0.85
unionFunction · 0.85
bindAllFunction · 0.85

Calls 2

isArgumentsFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected