This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MapObj = (obj, mapFn) -> | |
| if obj.length && obj.join | |
| return obj.map(mapFn) | |
| result = {} | |
| result[key] = mapFn(val, key) for key, val of obj | |
| result | |
| FilterObj = (obj, filterFn) -> | |
| if obj.length && obj.join | |
| return obj.filter(filterFn) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hasProperty(obj, prop) { | |
| return obj[prop] !== undefined; | |
| }; | |
| Array.prototype.callFunction = function(target, key) { | |
| var args = [].splice.call(arguments, 0).slice(2); | |
| this.forEach(function(elem) { | |
| try { | |
| if (hasProperty(elem, key) && typeof elem[key] == 'function') { |
NewerOlder