hubs
Version:
``` Caryl ------ courier3 / \ / \ courier1 courier2
24 lines (15 loc) • 444 B
JavaScript
class Protocol{
constructor(){
this.requestors = Object.create(null)
this.prepares = Object.create(null)
}
registerRequestor({name, realize, prepare}){
this.requestors[name] = realize
prepare && (this.prepares[name] = prepare)
}
use(name, config){
this.prepares[name] && this.prepares[name](config)
return this.requestors[name]
}
}
module.exports = new Protocol()