Library for javascript below ES6, which allows to write inline async calls.
For ES6 is preffered to use generators, for example co
Comparison to async
style:
Function inside sequencer
parsed as a string.
All function calls prefixed with ~~
and ~!
are executed first,
and substituted by resulting value. Prefix types are:
~~
for traditional callback(err, result)~!
for promises
npm i mo-sequencer --save
or for client-side projects:
bower i async --save
bower i mo-sequencer --save
<script type="text/javascript" src="/bower_components/async/dist/async.js"></script>
<script type="text/javascript" src="/bower_components/mo-sequencer/mo-sequencer.js"></script>
Please, copy comment when use sequencer, because ~~
and ~!
- it's new "coordinate system" which may confuse your colleagues.
var sequencer = require('mo-sequencer');
// (~˘▾˘)~ mo-sequencer: ~~ is call of async function; ~! is call of promise
sequencer((__o, __0) => { eval(__o)}, () => {
});
Let's see explanation of what happens on example:
Download repo and check if example.js
looks cool in your favorite IDE.
git clone https://github.com/mojects/mo-sequencer.git
cd mo-sequencer
npm i
node example.js
Examples above work well on node and browser. Though there is list of limitations (see how to facilitate for their elimination) In current prototype following is not supported:
- Not supported: declarations of
var
. (need to declare outside of sequencer, like in Explanation example) - Not supported: sub-functions in body of sequencer
- Not supported: async call inside of another async call (as argument)
- Not supported: if-conditions/switches/loops
MIT