UNPKG

@httpc/kit

Version:

httpc toolbox for building function-based API with minimal code and end-to-end type safety

33 lines (32 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tsyringe_1 = require("tsyringe"); const keys_1 = require("./keys"); /* * Add extra functionality to tsyringe container * - self registration, so it can resolve itself */ // self register patchSelfRegister(tsyringe_1.container); function patchSelfRegister(container) { registerSelf(container); // self register on child patch(container, "createChildContainer", function (original) { const value = original.call(this); patchSelfRegister(value); return value; }); patch(container, "reset", function (original) { original.call(this); registerSelf(this); }); function registerSelf(container) { container.registerInstance(keys_1.CONTAINER_KEY, container); } } function patch(instance, method, body) { const oldMethod = instance[method]; instance[method] = function () { return body.apply(this, [oldMethod, ...arguments]); }; }