~launchpad-pqm/lazr-js/toolchain

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/collection/array-invoke-debug.js

  • Committer: Sidnei da Silva
  • Date: 2009-11-16 00:51:29 UTC
  • mto: This revision was merged to the branch mainline in revision 154.
  • Revision ID: sidnei.da.silva@canonical.com-20091116005129-8ibwjlboa38glaw5
- Improved generation of skin modules and revamped combo service to make it more twisty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
 
Code licensed under the BSD License:
4
 
http://developer.yahoo.com/yui/license.html
5
 
version: 3.2.0
6
 
build: 2676
7
 
*/
8
 
YUI.add('array-invoke', function(Y) {
9
 
 
10
 
/**
11
 
 * Collection utilities beyond what is provided in the YUI core
12
 
 * @module collection
13
 
 * @submodule array-invoke
14
 
 */
15
 
 
16
 
/**
17
 
 * Adds the <code>Y.Array.invoke( items, methodName )</code> utility method.
18
 
 * @class YUI~array~invoke
19
 
 */
20
 
 
21
 
/**
22
 
 * <p>Execute a named method on an array of objects.  Items in the list that do
23
 
 * not have a function by that name will be skipped. For example,
24
 
 * <code>Y.Array.invoke( arrayOfDrags, 'plug', Y.Plugin.DDProxy );</code></p>
25
 
 *
26
 
 * <p>The return values from each call are returned in an array.</p>
27
 
 *
28
 
 * @method invoke
29
 
 * @static
30
 
 * @param items { Array } Array of objects supporting the named method
31
 
 * @param name { String } the name of the method to execute on each item
32
 
 * @param args* { mixed } Any number of additional args are passed as
33
 
 *                        parameters to the execution of the named method.
34
 
 * @return { Array } All return values, indexed according to item index.
35
 
 */
36
 
Y.Array.invoke = function ( items, name ) {
37
 
    var args       = Y.Array( arguments, 2, true ),
38
 
        isFunction = Y.Lang.isFunction,
39
 
        ret        = [];
40
 
 
41
 
    Y.Array.each( Y.Array( items ), function ( item, i ) {
42
 
        if ( isFunction( item[ name ] ) ) {
43
 
            ret[i] = item[ name ].apply( item, args );
44
 
        }
45
 
    });
46
 
 
47
 
    return ret;
48
 
};
49
 
 
50
 
 
51
 
}, '3.2.0' );