summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js')
-rw-r--r--tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js
new file mode 100644
index 0000000000..aa8702bceb
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/baseFlatten.js
@@ -0,0 +1,43 @@
+var isArguments = require('../lang/isArguments'),
+ isArray = require('../lang/isArray'),
+ isArrayLike = require('./isArrayLike'),
+ 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-like 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) && isArrayLike(value) &&
+ (isStrict || 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;
+
+ while (++valIndex < valLength) {
+ result[++resIndex] = value[valIndex];
+ }
+ } else if (!isStrict) {
+ result[++resIndex] = value;
+ }
+ }
+ return result;
+}
+
+module.exports = baseFlatten;