2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('arraylist-filter', function(Y) {
11 * Collection utilities beyond what is provided in the YUI core
13 * @submodule arraylist-filter
17 * Adds filter method to ArrayList prototype
18 * @class ArrayList~filter
20 Y.mix(Y.ArrayList.prototype, {
23 * <p>Create a new ArrayList (or augmenting class instance) from a subset
24 * of items as determined by the boolean function passed as the
25 * argument. The original ArrayList is unchanged.</p>
27 * <p>The validator signature is <code>validator( item )</code>.</p>
30 * @param { Function } validator Boolean function to determine in or out.
31 * @return { ArrayList } New instance based on who passed the validator.
33 filter: function(validator) {
36 Y.Array.each(this._items, function(item, i) {
39 if (validator(item)) {
44 return new this.constructor(items);
50 }, '3.3.0' ,{requires:['arraylist']});