0.0.5 • Published 7 years ago

ssfq v0.0.5

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

Queue Build Status

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

  • task a new task is beeing processed
  • locked queue is busy processing tasks
  • unlocked queue is idle
  • paused queue was paused and won't process any task until resumed
  • resumed queue will continue processing tasks
0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago