mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
more work
This commit is contained in:
44
node_modules/lodash/internal/baseFlatten.js
generated
vendored
Normal file
44
node_modules/lodash/internal/baseFlatten.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
var isArguments = require('../lang/isArguments'),
|
||||
isArray = require('../lang/isArray'),
|
||||
isLength = require('./isLength'),
|
||||
isObjectLike = require('./isObjectLike');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.flatten` with added support for restricting
|
||||
* flattening and specifying the start index.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} isDeep Specify a deep flatten.
|
||||
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
|
||||
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
value = baseFlatten(value, isDeep, isStrict);
|
||||
}
|
||||
var valIndex = -1,
|
||||
valLength = value.length;
|
||||
|
||||
result.length += valLength;
|
||||
while (++valIndex < valLength) {
|
||||
result[++resIndex] = value[valIndex];
|
||||
}
|
||||
} else if (!isStrict) {
|
||||
result[++resIndex] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = baseFlatten;
|
Reference in New Issue
Block a user