blob: 4a51faa0e2f41c02fcbb0b8235ac89fdd9fe46a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
const methods = {}
const constructors = {}
export function registerMethods (name, m) {
if (typeof name == 'object') {
for (let [_name, _m] of Object.entries(name)) {
registerMethods(_name, _m)
}
}
methods[name] = Object.assign(methods[name] || {}, m)
}
export function getMethodsFor (name) {
return methods[name]
}
// FIXME: save memory?
export function cleanMethods () {
methods = {}
}
export function registerConstructor (name, setup) {
constructors[name] = setup
}
export function getConstructor (name) {
return {setup: constructors[name], name}
}
|