zutils/dist/index.js
2024-01-17 15:51:16 +08:00

27 lines
692 B
JavaScript

// src/common/ZError.ts
var ZError = class {
constructor(statusCode, message) {
this.statusCode = statusCode;
this.message = message;
}
};
// src/decorators/singleton.ts
var SINGLETON_KEY = Symbol();
var singleton = (classTarget) => new Proxy(classTarget, {
construct(target, argumentsList, newTarget) {
if (target.prototype !== newTarget.prototype) {
return Reflect.construct(target, argumentsList, newTarget);
}
if (!target[SINGLETON_KEY]) {
target[SINGLETON_KEY] = Reflect.construct(target, argumentsList, newTarget);
}
return target[SINGLETON_KEY];
}
});
export {
SINGLETON_KEY,
ZError,
singleton
};
//# sourceMappingURL=index.js.map