| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 13 101 101 2 99 1 | define(function(){
/**
* internal method used to create other collection modules.
* @version 0.2.0 (2012/10/30)
*/
function makeCollectionMethod(arrMethod, objMethod, defaultReturn) {
return function(){
var args = Array.prototype.slice.call(arguments);
if (args[0] == null) {
return defaultReturn;
}
// array-like is treated as array
return (typeof args[0].length === 'number')? arrMethod.apply(null, args) : objMethod.apply(null, args);
};
}
return makeCollectionMethod;
});
|