0.0.5 • Published 9 years ago
ssfq v0.0.5
Queue 
Getting Started
const Queue = require('ssfq')
const myQueue = new Queue(workerCount)
myQueue.push((next) => {
/* do something */
next()
})class YourClass extends Queue {
find(query) {
this.push((next) => {
this._somedb.find(query, (docs) => {
this.result = docs
})
})
return this
}
each(fn) {
this.push((next) => {
this.result.forEach(fn)
})
return this
}
}
var db = YourClass()
db.find({
foo: 'bar'
})
.each((doc) => {
console.log(doc)
})Methods
push(task, options)
push task to queue
queue.push((next) => {
/* do something */
next()
}, {
priority: 2
})options
- priority number, highest priority get executed first. default:
0
resume()
unpause queue and continue processing tasks
queue.resume()pause()
pause queue (after processing current task)
queue.pause()Events
taska new task is beeing processedlockedqueue is busy processing tasksunlockedqueue is idlepausedqueue was paused and won't process any task until resumedresumedqueue will continue processing tasks