Package Exports
- async2
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (async2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Async2.js
Better asynchronous javascript flow control in 98 lines or 2.59KB minified (990 bytes gzipped).
Inspired by async, mini-async, Mocha, Chai, Should.js, and IcedCoffeeScript/TameJs libraries.
Flow Control
- begin / try / new : chainable instantiation; not required but sometimes useful
- beforeAll / before : non-blocking function called once before first task
- beforeEach : non-blocking function called once before each task
- serial / series / blocking / waterfall : blocking function called in order; results optionally waterfalled.
- parallel / nonblocking : non-blocking function called in order
- do / then / auto : optionally blocking function called in order; determined by length of arguments callback expects
- afterEach / between / inbetween : non-blocking function called once after each task
- error / catch / rescue : blocking function called when error occurs
- success / else : non-blocking function called after all tasks have completed, but only if no errors occur
- end / finally / ensure / afterAll / after / complete / done : blocking function called after all tasks have completed
- whilst : provide test, iterator, and callback functions. will iterate until test passes, then execute callback
Quick Examples
First, reflect upon our haiku mantra:
"thoughtful single-chain
order of operations
escape callback hell!"
Then, observe in action:
async('pretend/path/to/file') # accepts initial input passed via waterfall to serial
.serial(fs.readFile) # block until data is read
.parallel [ tweet, fbook, gplus ], # push data to 3 services simultaneously
(err, data) -> # execute once all above is complete
#done()
For the latest examples, review the easy-to-follow ./test/test.coffee.
Or try it immediately in your browser with codepen.
TODO
- potential node.js madness: each series becomes its own cpu thread, each parallel becomes its own gpu thread.
"GPUs have evolved to the point where many real-world applications are easily implemented on them and run significantly faster than on multi-core systems. Future computing architectures will be hybrid systems with parallel-core GPUs working in tandem with multi-core CPUs.' -- Professor Jack Dongarra, Director of the Innovative Computing Laboratory, The University of Tennessee