summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/lodash/_baseFind.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/lodash/_baseFind.js')
-rw-r--r--tools/eslint/node_modules/lodash/_baseFind.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/lodash/_baseFind.js b/tools/eslint/node_modules/lodash/_baseFind.js
new file mode 100644
index 0000000000..535f7f3537
--- /dev/null
+++ b/tools/eslint/node_modules/lodash/_baseFind.js
@@ -0,0 +1,24 @@
+/**
+ * The base implementation of methods like `_.find` and `_.findKey`, without
+ * support for iteratee shorthands, which iterates over `collection` using
+ * `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to search.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {Function} eachFunc The function to iterate over `collection`.
+ * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
+ * @returns {*} Returns the found element or its key, else `undefined`.
+ */
+function baseFind(collection, predicate, eachFunc, retKey) {
+ var result;
+ eachFunc(collection, function(value, key, collection) {
+ if (predicate(value, key, collection)) {
+ result = retKey ? key : value;
+ return false;
+ }
+ });
+ return result;
+}
+
+module.exports = baseFind;