UNPKG

callable-instance2

Version:

Instances of classes which are directly callable as functions.

42 lines (37 loc) 1.38 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CallableInstance2 = {})); })(this, (function (exports) { 'use strict'; // @ts-nocheck function CallableInstance(property) { // @ts-ignore const func = this.constructor.prototype[property]; const apply = function () { return func.apply(apply, arguments); }; // @ts-ignore Object.setPrototypeOf(apply, this.constructor.prototype); Object.getOwnPropertyNames(func).forEach(function (p) { Object.defineProperty(apply, p, Object.getOwnPropertyDescriptor(func, p)); }); return apply; } CallableInstance.prototype = /*#__PURE__*/Object.create(Function.prototype); // @ts-ignore { Object.defineProperty(CallableInstance, "__esModule", { value: true }); Object.defineProperty(CallableInstance, 'CallableInstance', { value: CallableInstance }); Object.defineProperty(CallableInstance, 'default', { value: CallableInstance }); } exports.CallableInstance = CallableInstance; exports.default = CallableInstance; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=index.umd.development.cjs.map