aboutsummaryrefslogtreecommitdiffstats
path: root/src/methods.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods.js')
-rw-r--r--src/methods.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/methods.js b/src/methods.js
new file mode 100644
index 0000000..4a51faa
--- /dev/null
+++ b/src/methods.js
@@ -0,0 +1,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}
+}