0.0.3 • Published 7 years ago

asynccode v0.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

asyncCode

Creates a new call stack for a code block

For use in nodejs:

npm install asynccode --save

Now for every async code block'

/* uncomment for use with nodejs */
// var requirejs = require('requirejs');
// requirejs.config({
//   nodeRequire: require
// });

requirejs(['../asynccode'],function(async){
  var max = 1024 * 1024;
  var i = 0;

  var next = function(){
    if(i < max){
      async(function(){
        // .. do your async thing
        Math.sqrt(i);
        i++;
        next();
      });
    }else{
      console.log('ready'); // eslint-disable-line
    }
  };
  next();
});
const myAsyncFunc = function(callback){
  // Function scope/codeblock
  asyncCode(
    // This is executed in another code block
    function(){
      // Do your async thing
      // ....
      // .....
      callback('ok');
    }
  );
  return this;
}
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago