wsh.js
Version:
WebSHell provides a toolkit for building bash-like command line consoles for web pages.
22 lines (16 loc) • 407 B
JavaScript
class Base {
constructor(config = {}) {
this.debug = !!config.debug;
this.eventHandlers = {};
}
_log(...args) {
this.debug && console.log(...args);
}
async _trigger(event, ...args) {
return this.eventHandlers[event] && this.eventHandlers[event](...args);
}
on(event, fn) {
this.eventHandlers[event] = fn;
}
}
export default Base;