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
'use strict' | |
class Callable extends Function { | |
constructor() { | |
super() | |
return new Proxy(this, { | |
apply: (target, thisArg, args) => target._call(...args) | |
}) | |
} | |
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
'use strict' | |
class Callable extends Function { | |
constructor() { | |
var closure = function(...args) { return closure._call(...args) } | |
// Or without the spread/rest operator: | |
// var closure = function() { | |
// return closure._call.apply(closure, arguments) | |
// } | |
return Object.setPrototypeOf(closure, new.target.prototype) |
OlderNewer