Skip to content

mojects/mo-sequencer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(˘▾˘) mo-sequencer

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:

Comparison to async

How it works

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

Install

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>

Copy-paste template

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)}, () => {
        
    });

Explanation

Let's see explanation of what happens on example:

Explanation

Test on your machine

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

Current implementation - is prototype

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

Contribution

Contribution page.

License

MIT

About

Allows to write inline async calls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published