Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types improvements #152

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@ interface IDefinitorInstance<N extends object, S> {
interface IDefinitor<P extends object, SubTypeName extends string> {
<PP extends object, T, M extends Proto<P, Proto<PP, T>>, S extends SN & M>(this: unknown, TypeName: SubTypeName, constructHandler: IDEF<T>, proto?: PP, config?: object): IDefinitorInstance<M, S>;
}
type hooksTypes = 'preCreation' | 'postCreation' | 'creationError';
type hooksOpts = {
TypeName: string;
args: unknown[];
existentInstance: object;
inheritedInstance: object;
};
type hook = {
(opts: hooksOpts): void;
};
export declare const define: <T, P extends object, N extends Proto<P, T>, SubTypeName extends string, S extends SN & N, R extends {
new (): { [key in keyof S]: S[key]; };
define: IDefinitor<N, SubTypeName>;
registerHook: (hookType: hooksTypes, cb: hook) => void;
}>(this: unknown, TypeName?: string, constructHandler?: IDEF<T> | undefined, proto?: P | undefined, config?: {}) => R;
export declare const lookup: TypeLookup;
export declare const apply: <E extends object, T extends object, S extends Proto<E, T>>(entity: E, Constructor: IDEF<T>, args?: unknown[]) => { [key in keyof S]: S[key]; };
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mnemonica",
"version": "0.9.959",
"version": "0.9.970",
"description": "abstract technique that aids information retention : instance inheritance system",
"type": "commonjs",
"main": "./build/index.js",
Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ interface IDefinitor<P extends object, SubTypeName extends string> {
): IDefinitorInstance<M, S>
}

type hooksTypes = 'preCreation' | 'postCreation' | 'creationError'
type hooksOpts = {
TypeName: string,
args: unknown[],
existentInstance: object,
inheritedInstance: object,
}
type hook = {
(opts: hooksOpts): void
}

export const define = function <
T,
// K extends IDEF<T>,
Expand All @@ -58,6 +69,7 @@ export const define = function <
[key in keyof S]: S[key]
}
define: IDefinitor<N, SubTypeName>
registerHook: (hookType: hooksTypes, cb: hook) => void
},
> (
this: unknown,
Expand Down
Loading