.("""") (j)
(_(_ __(_ ) (n o d e)
_ _ _ _ / / / (n) (s)
))`)`) ___ )L __ __ / / / n \|/ \|/
((,(,' ((_( (( (('(| n \|/ | |
Part of the Node Water collection.
- lazy-functions - Grow your node.js project with less effort.
- On github.com
- On npmjs.org
This library is for Victor Tugelbend (and lazy people like him) for whom "Having to haul arround extra poundage [is] far too much effort, so he saw to it that he never put it on and he kept himself in trim becuase doing things with decent muscles was far less effort than trying to achive things with bags of flab". Pratchett, T
So What Does it Do?!
Povides asynchronous control flow wrappers designed to read naturally, using Caolan McMahon excellent async library under the bonnet.
Installation
Official releases can be obtained from:
- github.com - the tags section provides links to zip or tar.gz packages.
- npm - use
npm install lazy-functions
The lastest developed code may node have not have been released, but can always be found from:
- github.com - the project homepage provides links to all the source code, branches and issue tracking.
Concepts
There are two common node.js conventions followed. Firstly an asynchronous function has the following signature:
;
If you execute the function with the correct number of arguments the result of it's execution are returned using the callback. A callback function has the following signature:
Where:
err
contains a value only if an error has occured. Otherwise it isnull
.data
contains any results and may benull
orundefined
.
Most asyncrhonous node.js code follows these conventions but not all. You wil need to watch out for those that don't follow the convention, for example:
- async.auto calls asynchronous functions with func(callback, results).
- fs.exists calls it's callback callback(exisits) with no err argument.
Both have good reasons for being like this but it means
Credits
- John Resig - http://ejohn.org/blog/partial-functions-in-javascript/
- Caolan McMahon - https://github.com/caolan/async
References
@book{pratchett2009moving, title={Moving Pictures: (Discworld Novel 10)}, author={Pratchett, T.}, isbn={9781407034737}, series={Discworld Novels}, url={http://books.google.co.uk/books?id=gDnb8AlIMAUC}, year={2009}, publisher={Transworld}}