-
Notifications
You must be signed in to change notification settings - Fork 0
/
duckHelpers.js
41 lines (36 loc) · 919 Bytes
/
duckHelpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Created with JetBrains WebStorm.
* User: freitas
* Date: 03/04/2013
* Time: 20:05
* To change this template use File | Settings | File Templates.
*/
var method = function(obj, key){
return function(){
return obj[key].apply(obj, arguments);
};
};
var getProperty = function(obj, keyOrPath){
obj = typeof obj === "function" ? obj() : obj;
if (keyOrPath.forEach){
var property;
keyOrPath.forEach(function(key){
property = obj[key];
});
return property;
}
return obj[key];
};
var property = function(obj, key){
return function(){
return obj[key];
}
};
var callMethod = function(methodKey, objectsArray, argsArray){
var returnValues = [];
objectsArray.forEach(function(obj){
var method = obj[methodKey];
returnValues.push( method.apply(obj, argsArray) );
});
return returnValues;
};