mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Move some screen utilities to the global util directory so that they can be used for other things too.
This commit is contained in:
parent
ae9f2b5ab0
commit
5bb05f52f6
4 changed files with 3 additions and 3 deletions
30
lib/util/statequeue.js
Normal file
30
lib/util/statequeue.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
function StateQueue() {
|
||||
this.queue = []
|
||||
}
|
||||
|
||||
StateQueue.prototype.next = function() {
|
||||
return this.queue.shift()
|
||||
}
|
||||
|
||||
StateQueue.prototype.empty = function() {
|
||||
return this.queue.length === 0
|
||||
}
|
||||
|
||||
StateQueue.prototype.push = function(state) {
|
||||
var found = false
|
||||
|
||||
// Not super efficient, but this shouldn't be running all the time anyway.
|
||||
for (var i = 0, l = this.queue.length; i < l; ++i) {
|
||||
if (this.queue[i] === state) {
|
||||
this.queue.splice(i + 1)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
this.queue.push(state)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StateQueue
|
Loading…
Add table
Add a link
Reference in a new issue