Version 1
[yaffs-website] / node_modules / grunt-legacy-log / node_modules / lodash / internal / baseFind.js
diff --git a/node_modules/grunt-legacy-log/node_modules/lodash/internal/baseFind.js b/node_modules/grunt-legacy-log/node_modules/lodash/internal/baseFind.js
new file mode 100644 (file)
index 0000000..be5848f
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
+ * without support for callback shorthands and `this` binding, which iterates
+ * over `collection` using the provided `eachFunc`.
+ *
+ * @private
+ * @param {Array|Object|string} 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;