Skip to content

wannabesrevenge/dillydally

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dillydally

Install

npm install dillydally

How to use

var queue = require('dillydally');

// Normal function
function foo() { return 'party'; }

// Function returns a promise
function bar() { return Promise.resolve('poop'); }

// Function with arguments
function yarg(a) { return a; }

// Add a function to run in the job queue
queue.addJob(foo).then(console.log) // prints 'party'
queue.addJob(bar).then(console.log) // prints 'poop'
queue.addJob(yarg, 'derp').then(console.log) // prints 'derp'

// waits 500 ms then prints 'party'
queue.addJob(500, foo).then(console.log)

// waits 1000 ms after the previous job then prints 'poop'
queue.addJob(1000, bar).then(console.log)

// prints 'poop' immediately after the previous job
queue.addJob(bar).then(console.log)

// Specify the context for the function to run in
function baz() { return this.test }
queue.addJob({context: {test: 'derp'}}, baz).then(console.log) // prints 'derp'

// Specify context and delay
queue.addJob({delay: 500, context: {test: 'derp'}}, baz).then(console.log) // prints 'derp' after 500ms

// Supply your own Promise lib
queue.Promise = require('bluebird');

About

In memory job and function queue for Node JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published