Skip to content

Instantly share code, notes, and snippets.

@mafintosh
Created March 6, 2015 22:22
Show Gist options
  • Save mafintosh/203859171ed19a1b2e57 to your computer and use it in GitHub Desktop.
Save mafintosh/203859171ed19a1b2e57 to your computer and use it in GitHub Desktop.
var atomicQueue = require(...)
var queue = atomicQueue(db, function (data, cb) {
console.log('got some work', data)
// do stuff ...
cb(null, result) // if no error this work will be removed from the leveldb
})
// write will add this 'work' to the leveldb
queue.write({some: 'world'})
// where there is a work 'result' it will be pushed to the readable stream
queue.on('data', function (data) {
console.log(data) // the work result
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment