From 23ebc851b1fd21f8413c8cc474662a47b47e45d8 Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Mon, 7 Sep 2009 14:12:55 +0100 Subject: [PATCH] doc: merge old docs for Enumerable#detect, add example --- src/lang/enumerable.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lang/enumerable.js b/src/lang/enumerable.js index 51d2cb2..3f6a6b9 100644 --- a/src/lang/enumerable.js +++ b/src/lang/enumerable.js @@ -225,9 +225,18 @@ var Enumerable = (function() { /** * Enumerable#detect(iterator[, context]) -> firstElement | undefined + * - iterator (Function): The iterator function to apply to each element + * in the array. + * - context (Object): An optional object to use as `this` within + * calls to the iterator. * - * Finds the first element for which the iterator returns a "truthy" value. + * Returns the first element for which the iterator returns a truthy value. * Aliased by the [[Enumerable#find]] method. + * + * ### Example + * + * [1, 7, -2, -4, 5].detect(function(n) { return n < 0; }) + * // -> -2 **/ function detect(iterator, context) { var result;