~jonas-drange/ubuntu-webcatalog/tos-redirect

« back to all changes in this revision

Viewing changes to src/webcatalog/static/yui/3.10.3/build/array-invoke/array-invoke-debug.js

  • Committer: Tarmac
  • Author(s): Stephen Stewart
  • Date: 2013-06-26 09:19:32 UTC
  • mfrom: (184.1.4 ubuntu-global-nav)
  • Revision ID: tarmac-20130626091932-8urtuli368k8p7ds
[r=beuno,jonas-drange] add ubuntu global nav to apps.ubuntu.com

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.10.3 (build 2fb5187)
 
3
Copyright 2013 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
 
 
8
YUI.add('array-invoke', function (Y, NAME) {
 
9
 
 
10
/**
 
11
@module collection
 
12
@submodule array-invoke
 
13
*/
 
14
 
 
15
/**
 
16
Executes a named method on each item in an array of objects. Items in the array
 
17
that do not have a function by that name will be skipped.
 
18
 
 
19
@example
 
20
 
 
21
    Y.Array.invoke(arrayOfDrags, 'plug', Y.Plugin.DDProxy);
 
22
 
 
23
@method invoke
 
24
@param {Array} items Array of objects supporting the named method.
 
25
@param {String} name the name of the method to execute on each item.
 
26
@param {Any} [args*] Any number of additional args are passed as parameters to
 
27
  the execution of the named method.
 
28
@return {Array} All return values, indexed according to the item index.
 
29
@static
 
30
@for Array
 
31
**/
 
32
Y.Array.invoke = function(items, name) {
 
33
    var args = Y.Array(arguments, 2, true),
 
34
        isFunction = Y.Lang.isFunction,
 
35
        ret = [];
 
36
 
 
37
    Y.Array.each(Y.Array(items), function(item, i) {
 
38
        if (item && isFunction(item[name])) {
 
39
            ret[i] = item[name].apply(item, args);
 
40
        }
 
41
    });
 
42
 
 
43
    return ret;
 
44
};
 
45
 
 
46
 
 
47
}, '3.10.3', {"requires": ["yui-base"]});