3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('array-invoke', function(Y) {
11
@submodule array-invoke
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.
20
Y.Array.invoke(arrayOfDrags, 'plug', Y.Plugin.DDProxy);
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.
31
Y.Array.invoke = function(items, name) {
32
var args = Y.Array(arguments, 2, true),
33
isFunction = Y.Lang.isFunction,
36
Y.Array.each(Y.Array(items), function(item, i) {
37
if (item && isFunction(item[name])) {
38
ret[i] = item[name].apply(item, args);
46
}, '3.5.0' ,{requires:['yui-base']});