Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mo-sequencer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mo-sequencer

Allows to write inline async calls in js

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

(˘▾˘) mo-sequencer

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

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

Install

npm i mo-sequencer --save

or

bower i mo-sequencer --save

Usage

    var someObject, someValue;
    // (~˘▾˘)~ mo-sequencer: ~~ is call of async function; ~! is call of promise
    sequencer((__o, __0) => { eval(__o)}, () => {
        someValue = ~~asyncMultiplier(1);
        someObject = {
            value1: ~~asyncMultiplier(10),
            value2: ~~asyncMultiplier(5)
        };
        console.log(someValue, someObject);
    });
    
    function asyncMultiplier(number, callback) {
        setTimeout(function() {
            callback(null, number * 2);
        }, 1);
    }

Explanation

Let's see explanation of what happens on example, which we could have in real environment:

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
npm i
node example.js

Current implementation - is prototype

Examples above work well on node and browser. Though there are 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 Usage 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

As you can see - prototype has pretty limited abilities. Though it already simplifies async code a lot and looks like a great potential!

Do not hesitate to post your random thoughts in chat and contribute.

Join the chat at https://gitter.im/mojects/mo-sequencer

Maybe, here together with you we will build future of async programming! :) Like this dude:

Future dude

FAQs

Package last updated on 21 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc