@civet/core
Version:
21 lines (20 loc) • 994 B
TypeScript
import { GenericObject } from './utilityTypes';
export type MetaLike<MetaI extends Meta> = MetaI | InferSchema<MetaI>;
export default class Meta<Schema extends GenericObject = GenericObject, Instance = unknown> {
readonly _inferSchema: Schema;
readonly _inferInstance: Instance;
data: Schema;
instance?: Instance;
constructor(base?: Schema, instance?: Instance);
clear: () => void;
delete: <Key extends keyof Schema>(key: Key) => Schema[Key];
entries: () => [keyof Schema, Schema[keyof Schema]][];
get: <Key extends keyof Schema>(key: Key) => Schema[Key];
has: (key: keyof Schema) => boolean;
keys: () => (keyof Schema)[];
set: <Key extends keyof Schema>(key: Key, value: Schema[Key]) => void;
values: () => Schema[keyof Schema][];
commit: (prev?: Schema, ignore?: (keyof Schema)[]) => Schema;
}
export type InferSchema<MetaI extends Meta> = MetaI['_inferSchema'];
export type InferInstance<MetaI extends Meta> = MetaI['_inferInstance'];