Merge branch 'MDL-32509' of git://github.com/danpoltawski/moodle
[moodle.git] / lib / yui / 3.5.0 / build / arraylist-filter / arraylist-filter.js
blob97edf9885c240f969cf7260cb6a6ffcc1e5625e6
1 /*
2 YUI 3.5.0 (build 5089)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add('arraylist-filter', function(Y) {
9 /**
10  * Collection utilities beyond what is provided in the YUI core
11  * @module collection
12  * @submodule arraylist-filter
13  * @deprecated Use ModelList or a custom subclass implementation
14  */
17  * Adds filter method to ArrayList prototype
18  */
19 Y.mix(Y.ArrayList.prototype, {
21     /**
22      * <p>Create a new ArrayList (or augmenting class instance) from a subset
23      * of items as determined by the boolean function passed as the
24      * argument.  The original ArrayList is unchanged.</p>
25      *
26      * <p>The validator signature is <code>validator( item )</code>.</p>
27      *
28      * @method filter
29      * @param { Function } validator Boolean function to determine in or out.
30      * @return { ArrayList } New instance based on who passed the validator.
31      * @for ArrayList
32      * @deprecated Use ModelList or a custom subclass implementation
33      */
34     filter: function(validator) {
35         var items = [];
37         Y.Array.each(this._items, function(item, i) {
38             item = this.item(i);
40             if (validator(item)) {
41                 items.push(item);
42             }
43         }, this);
45         return new this.constructor(items);
46     }
48 });
51 }, '3.5.0' ,{requires:['arraylist']});