I just finish reading the source code of Kriskowal's Q library and below are some notes (mainly to my future self). First in case someone stumble upon this post, this library is a complete implementation of the very cool pattern promise/defer for javascript and node.
- If performance is an issue, re-read the beginning about nextTick(). In the browser, setTimeout has a minimum value of 4ms, which *may* be problematic. There are workaround though.
- Need to start using uncurryThis. Basically it allow one to replace "".toUpperCase.call(s) by toUpperCase(s). Better for minimisation and also safer in case something modify Function.call.
- Hoisting make reading code difficult. Need to read the source twice to better understand.
- There are some functions (nfbind, synonym of denodify) which take a node-style function + callback and return a promise. Useful to refactor node code using promise/defer