aboutsummaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js')
-rw-r--r--tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js
new file mode 100644
index 0000000000..b55c39ba1c
--- /dev/null
+++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/createBaseEach.js
@@ -0,0 +1,31 @@
+var getLength = require('./getLength'),
+ isLength = require('./isLength'),
+ toObject = require('./toObject');
+
+/**
+ * Creates a `baseEach` or `baseEachRight` function.
+ *
+ * @private
+ * @param {Function} eachFunc The function to iterate over a collection.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseEach(eachFunc, fromRight) {
+ return function(collection, iteratee) {
+ var length = collection ? getLength(collection) : 0;
+ if (!isLength(length)) {
+ return eachFunc(collection, iteratee);
+ }
+ var index = fromRight ? length : -1,
+ iterable = toObject(collection);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (iteratee(iterable[index], index, iterable) === false) {
+ break;
+ }
+ }
+ return collection;
+ };
+}
+
+module.exports = createBaseEach;