l8r
queue multiple functions and run later
Niceties
- widely compatible and small codebase
Caveats
- there is no built in mechanism to receive return values; use callbacks or promises
- any unhandled exception will stop subsequent function calls
Installation
$ npm install --save l8r
Example
'use strict'; // let's queue socket listeners before we have a connection var L8r = ; var httpServer = ;var io = httpServer;var ioClient = 'http://localhost:3000'; // ... // queue client-side listenersvar clientListeners = ; { var self = smile: '=)' ; clientListeners;}; // ... // queue server-side listenersvar serverListeners = ; { serverListeners;}; // ... // now that it's later, add listenersserverListeners; // ... io;
API
add(fn)
-
#### fn
Required Type
Function
A function to be queued for calling later.
run([arguments])
Run all the functions added to the queue, passing in any arguments
-
#### arguments
Type:
Any
Parameters to pass into each function
apply(context, [parameters])
Run all the functions added to the queue, with context,
applying an array of parameters (if provided)
-
#### context
Required Type:
Object
-
#### parameters
Type:
Array
queue
The queue of functions to be called later
q
An alias for `queue`
License
ISC © Buster Collings