Release package version 0.0.2
All checks were successful
CI / build (push) Successful in 24s

Update models, added parser
This commit is contained in:
Andrey Kernichniy 2026-03-14 15:12:21 +07:00
parent 0f8546bc69
commit 7742cc7a83
22 changed files with 449 additions and 41 deletions

View file

@ -1,15 +1,5 @@
import { ModelConstructor } from "../interfaces";
export const IMMUTABLE_KEY = Symbol("secret");
export const IMMUTABLE_FIELDS = new WeakMap<ModelConstructor, Set<string>>();
export function immutable(value: unknown, context: ClassFieldDecoratorContext) {
context.addInitializer(function () {
const ctor = this.constructor as ModelConstructor;
let set = IMMUTABLE_FIELDS.get(ctor);
if (!set) {
set = new Set<string>();
IMMUTABLE_FIELDS.set(ctor, set);
}
set.add(context.name as string);
});
export function immutable(target: any, propertyKey: string) {
Reflect.defineMetadata(IMMUTABLE_KEY, true, target, propertyKey);
}