Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 651cfe2

Browse files
committed
feat(core): add fn to remove keys from catalogue; extend returns a clean up fn
1 parent d200e3e commit 651cfe2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libs/core/src/lib/renderer/catalogue.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ import type { NgtConstructorRepresentation } from '../types';
33

44
const catalogue: Record<string, NgtConstructorRepresentation> = {};
55

6-
export function extend(objects: object): void {
6+
export function extend(objects: object) {
7+
const keys = Object.keys(objects);
78
Object.assign(catalogue, objects);
9+
return () => {
10+
remove(...keys);
11+
};
12+
}
13+
14+
export function remove(...keys: string[]) {
15+
for (const key of keys) {
16+
delete catalogue[key];
17+
}
818
}
919

1020
export const NGT_CATALOGUE = new InjectionToken<typeof catalogue>('NGT_CATALOGUE', { factory: () => catalogue });

0 commit comments

Comments
 (0)