1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00
OpenSTF/lib/wire/seqqueue.js
2014-04-03 17:13:17 +09:00

26 lines
472 B
JavaScript

function SeqQueue() {
this.queue = []
this.seq = 0
}
SeqQueue.prototype.push = function(seq, handler) {
this.queue[seq] = handler
this.maybeDequeue()
}
SeqQueue.prototype.done = function(seq, handler) {
this.queue[seq] = handler
this.maybeDequeue()
}
SeqQueue.prototype.maybeDequeue = function() {
var handler
while ((handler = this.queue[this.seq])) {
this.queue[this.seq] = void 0
handler()
this.seq += 1
}
}
module.exports = SeqQueue