Version 1
[yaffs-website] / node_modules / grunt-legacy-log / node_modules / lodash / internal / createFind.js
diff --git a/node_modules/grunt-legacy-log/node_modules/lodash/internal/createFind.js b/node_modules/grunt-legacy-log/node_modules/lodash/internal/createFind.js
new file mode 100644 (file)
index 0000000..29bf580
--- /dev/null
@@ -0,0 +1,25 @@
+var baseCallback = require('./baseCallback'),
+    baseFind = require('./baseFind'),
+    baseFindIndex = require('./baseFindIndex'),
+    isArray = require('../lang/isArray');
+
+/**
+ * Creates a `_.find` or `_.findLast` 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 find function.
+ */
+function createFind(eachFunc, fromRight) {
+  return function(collection, predicate, thisArg) {
+    predicate = baseCallback(predicate, thisArg, 3);
+    if (isArray(collection)) {
+      var index = baseFindIndex(collection, predicate, fromRight);
+      return index > -1 ? collection[index] : undefined;
+    }
+    return baseFind(collection, predicate, eachFunc);
+  };
+}
+
+module.exports = createFind;