UNPKG

@hosoft/restful-api-framework

Version:

Base framework of the headless cms HoServer provided by http://helloreact.cn

29 lines (23 loc) 602 B
function CallbackFiller() { this.queues = {} } CallbackFiller.prototype.fill = function (key, err, data) { const waiting = this.queues[key] delete this.queues[key] if (waiting && waiting.length) { waiting.forEach(function (task) { task.cb(err, data) }) } } CallbackFiller.prototype.has = function (key) { return this.queues[key] } CallbackFiller.prototype.add = function (key, funcObj) { if (this.queues[key]) { this.queues[key].push(funcObj) } else { this.queues[key] = [funcObj] } } module.exports = CallbackFiller