123456789101112131415161718192021222324252627282930313233343536373839 |
- export const CallableInstance =
-
- (
-
- (
-
- function (property) {
- const self = this
- const constr = self.constructor
- const proto = (
-
-
- constr.prototype
- )
- const func = proto[property]
-
- const apply = function () {
- return func.apply(apply, arguments)
- }
- Object.setPrototypeOf(apply, proto)
- const names = Object.getOwnPropertyNames(func)
- for (const p of names) {
- const descriptor = Object.getOwnPropertyDescriptor(func, p)
- if (descriptor) Object.defineProperty(apply, p, descriptor)
- }
- return apply
- }
- )
- )
|