-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototypeHelper.js
More file actions
25 lines (25 loc) · 804 Bytes
/
prototypeHelper.js
File metadata and controls
25 lines (25 loc) · 804 Bytes
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
function bindWithTypes(name, func) {
Function.prototype[name] = func;
Object.prototype[name] = func;
String.prototype[name] = func;
Array.prototype[name] = func;
Boolean.prototype[name] = func;
}
module.exports = {
bindTypes(obj) {
bindWithTypes("whatIf", obj.whatIf);
bindWithTypes("whatIfNotNull", obj.whatIfNotNull);
bindWithTypes("whatIfNotUndefined", obj.whatIfNotUndefined);
bindWithTypes("whatIfNotNullOrEmpty", obj.whatIfNotNullOrEmpty);
},
monkeyPatchBind() {
var _bind = Function.prototype.apply.bind(Function.prototype.bind);
Object.defineProperty(Function.prototype, "bind", {
value: function(obj) {
var boundFunction = _bind(this, arguments);
boundFunction.boundObject = obj;
return boundFunction;
}
});
}
};