UNPKG

@k8ts/instruments

Version:

A collection of utilities and core components for k8ts.

33 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPrototypes = getPrototypes; exports.bind_own_methods = bind_own_methods; const immutable_1 = require("immutable"); function getPrototypes(target) { const prototypes = []; let proto = Object.getPrototypeOf(target); while (proto) { prototypes.push(proto); proto = Object.getPrototypeOf(proto); } return (0, immutable_1.List)(prototypes); } function bind_own_methods() { return (target) => { for (const [key, desc] of (0, immutable_1.Map)(Object.getOwnPropertyDescriptors(target.prototype))) { if (!desc.value || typeof desc.value !== "function") { continue; } const descValue = desc.value; delete desc.value; delete desc.writable; Object.defineProperty(target.prototype, key, { ...desc, get() { return descValue.bind(this); } }); } }; } //# sourceMappingURL=bind.js.map