Added first files
All checks were successful
CI / build (push) Successful in 21s

This commit is contained in:
Andrey Kernichniy 2026-03-08 12:31:52 +07:00
parent 41a325f5e1
commit 0f8546bc69
10 changed files with 149 additions and 1 deletions

View file

@ -0,0 +1,15 @@
import { ModelConstructor } from "../interfaces";
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);
});
}