Files
NapCatQQ/.pnpm-store/v3/files/a1/d368aa453643197ed04354858e86ed88ea23d4ac8465ce4894fe8b12a7a1a8bc17ccf4c9d29fce58e888ac29cd25e98238b875e29619c0d9db4486e06a3c93
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

42 lines
1.6 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveBindingPreDestroy = resolveBindingPreDestroy;
const common_1 = require("@inversifyjs/common");
const BindingType_1 = require("../../binding/models/BindingType");
const CACHE_KEY_TYPE = 'cache';
function resolveBindingPreDestroy(params, binding) {
if (binding.type === BindingType_1.bindingTypeValues.Instance) {
const classMetadata = params.getClassMetadata(binding.implementationType);
const instance = binding.cache
.value;
if ((0, common_1.isPromise)(instance)) {
return instance.then((instance) => resolveInstancePreDestroyMethods(classMetadata, instance));
}
else {
return resolveInstancePreDestroyMethods(classMetadata, instance);
}
}
}
function resolveInstancePreDestroyMethod(instance, methodName) {
if (typeof instance[methodName] === 'function') {
const result = instance[methodName]();
return result;
}
}
function resolveInstancePreDestroyMethods(classMetadata, instance) {
const preDestroyMethodNames = classMetadata.lifecycle.preDestroyMethodNames;
if (preDestroyMethodNames.size === 0) {
return;
}
let result = undefined;
for (const methodName of preDestroyMethodNames) {
if (result === undefined) {
result = resolveInstancePreDestroyMethod(instance, methodName);
}
else {
result = result.then(() => resolveInstancePreDestroyMethod(instance, methodName));
}
}
return result;
}
//# sourceMappingURL=resolveBindingPreDestroy.js.map