From 061321d17c07fda61e0cc1fd72608f37b3abe76c Mon Sep 17 00:00:00 2001 From: tjcrowder Date: Mon, 7 Sep 2009 14:03:50 +0100 Subject: [PATCH] doc: merge old docs for Enumerable#any --- src/lang/enumerable.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lang/enumerable.js b/src/lang/enumerable.js index 885710b..97be1ef 100644 --- a/src/lang/enumerable.js +++ b/src/lang/enumerable.js @@ -161,9 +161,25 @@ var Enumerable = (function() { /** * Enumerable#any([iterator = Prototype.K[, context]]) -> Boolean + * - iterator (Function): An optional function to use to evaluate + * each element in the array; the function should return the value to + * test. If this is not provided, the element itself is tested. + * - context (Object): An optional object to use as `this` within + * calls to the iterator. * - * Determines whether at least one element is boolean-equivalent to `true`, - * either directly or through computation by the provided iterator. + * Determines whether at least one element is truthy (boolean-equivalent to + * `true`), either directly or through computation by the provided iterator. + * + * ### Examples + * + * [].any() + * // -> false (empty arrays have no elements that could be truthy) + * + * $R(0, 2).any() + * // -> true (on the second loop, 1 is truthy) + * + * [2, 4, 6, 8, 10].any(function(n) { return n > 5; }) + * // -> true (the iterator will return true on 6) **/ function any(iterator, context) { iterator = iterator || Prototype.K;