Version 1
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / findLast.js
diff --git a/node_modules/grunt-legacy-log-utils/node_modules/lodash/findLast.js b/node_modules/grunt-legacy-log-utils/node_modules/lodash/findLast.js
new file mode 100644 (file)
index 0000000..0e5d593
--- /dev/null
@@ -0,0 +1,33 @@
+var baseEachRight = require('./_baseEachRight'),
+    baseFind = require('./_baseFind'),
+    baseFindIndex = require('./_baseFindIndex'),
+    baseIteratee = require('./_baseIteratee'),
+    isArray = require('./isArray');
+
+/**
+ * This method is like `_.find` except that it iterates over elements of
+ * `collection` from right to left.
+ *
+ * @static
+ * @memberOf _
+ * @category Collection
+ * @param {Array|Object} collection The collection to search.
+ * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
+ * @returns {*} Returns the matched element, else `undefined`.
+ * @example
+ *
+ * _.findLast([1, 2, 3, 4], function(n) {
+ *   return n % 2 == 1;
+ * });
+ * // => 3
+ */
+function findLast(collection, predicate) {
+  predicate = baseIteratee(predicate, 3);
+  if (isArray(collection)) {
+    var index = baseFindIndex(collection, predicate, true);
+    return index > -1 ? collection[index] : undefined;
+  }
+  return baseFind(collection, predicate, baseEachRight);
+}
+
+module.exports = findLast;