blob: e9572136421e13015bd28645c7f73bb8c3ec0a01 (
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
31
32
33
|
const methods = {}
const names = []
export function registerMethods (name, m) {
if (Array.isArray(name)) {
for (let _name of name) {
registerMethods(_name, m)
}
return
}
if (typeof name === 'object') {
for (let _name in name) {
registerMethods(_name, name[_name])
}
return
}
addMethodNames(Object.getOwnPropertyNames(m))
methods[name] = Object.assign(methods[name] || {}, m)
}
export function getMethodsFor (name) {
return methods[name] || {}
}
export function getMethodNames () {
return [ ...new Set(names) ]
}
export function addMethodNames (_names) {
names.push(..._names)
}
|