~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/array-invoke/array-invoke.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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('array-invoke', function(Y) {
8
 
 
9
 
/**
10
 
@module collection
11
 
@submodule array-invoke
12
 
*/
13
 
 
14
 
/**
15
 
Executes a named method on each item in an array of objects. Items in the array
16
 
that do not have a function by that name will be skipped.
17
 
 
18
 
@example
19
 
 
20
 
    Y.Array.invoke(arrayOfDrags, 'plug', Y.Plugin.DDProxy);
21
 
 
22
 
@method invoke
23
 
@param {Array} items Array of objects supporting the named method.
24
 
@param {String} name the name of the method to execute on each item.
25
 
@param {Any} [args*] Any number of additional args are passed as parameters to
26
 
  the execution of the named method.
27
 
@return {Array} All return values, indexed according to the item index.
28
 
@static
29
 
@for Array
30
 
**/
31
 
Y.Array.invoke = function(items, name) {
32
 
    var args = Y.Array(arguments, 2, true),
33
 
        isFunction = Y.Lang.isFunction,
34
 
        ret = [];
35
 
 
36
 
    Y.Array.each(Y.Array(items), function(item, i) {
37
 
        if (item && isFunction(item[name])) {
38
 
            ret[i] = item[name].apply(item, args);
39
 
        }
40
 
    });
41
 
 
42
 
    return ret;
43
 
};
44
 
 
45
 
 
46
 
}, '3.5.0' ,{requires:['yui-base']});