1.5.1 • Published 7 years ago

queuey v1.5.1

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

queuey

Usage

const queues = require('queuey')('./testdb.json')

const callGrandmas = queues.queue({
  name: 'grandmas',
  worker: function (grandma) {
    // do stuff
    // optionally return Promise
    return promiseSometimeLater(function () {
      console.log('calling grandma ' + grandma)
    })
  }
})

const callGrandpas = queues.queue({
  name: 'grandpas',
  worker: function (grandpa) {
    // do stuff
    // optionally return Promise
    return promiseSometimeLater(function () {
      console.log('calling grandpa ' + grandpa)
    })
  }
})

callGrandpas.enqueue('Bill')
callGrandpas.enqueue('Ted')
callGrandpas.enqueue('Rufus')

callGrandmas.enqueue('Beyonce')
callGrandmas.enqueue('Rachel McAdams')
callGrandmas.enqueue('Gluugfrinksnoorg')

function promiseSometimeLater (fn) {
  return new Promise(resolve => {
    setTimeout(function () {
      fn()
      resolve()
    }, Math.random() * 1000 | 0)
  })
}

// calling grandpa Bill
// calling grandma Beyonce
// calling grandpa Ted
// calling grandma Rachel McAdams
// calling grandma Gluugfrinksnoorg
// calling grandpa Rufus
1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago