started rewrite

This commit is contained in:
Benjamin Kyd
2020-07-13 19:06:32 +01:00
parent 33edf59562
commit 7209b736cb
14 changed files with 1 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
let commands = {};
exports.endpoint = function endpoint (match, handler) {
commands[match] = handler;
};
exports.apply = function apply (command, context) {
let keys = Object.keys(commands);
for (let i = 0; i < keys.length; i++) {
let match = command.match(new RegExp(keys[i]));
if (match) {
commands[keys[i]](match, context);
return true;
}
}
return false;
};