ycatch

1.0.2 • Public • Published

ycatch

Probably useless until node has destructuring assignment. It can be used without it though.

api

var read = intercept(thunk(fs.readFile));
var a = read('index.js', 'utf8');
var c = read('package.json', 'utf8');
 
var [[erra, a], [errb, b]] = yield [a, b];
if(erra) throw erra;
if(errb) throw errb;
assert(a.indexOf('exports') > 0)
assert(b.indexOf('devDependencies') > 0)
function sleep(ms) {
  return function(done){
    setTimeout(done, ms);
  };
}
 
var work = intercept(function *(){
  yield sleep(50);
  return 'yay';
});
 
var [, a] = yield work;
assert('yay' === a);
var [, b] = yield work;
assert('yay' === b);
var [, c] = yield work;
assert('yay' === c);
 
var [[, a], [, b], [, c]] = yield [work, work, work];
assert('yay' === a);
assert('yay' === b);
assert('yay' === c);

Dependents (0)

Package Sidebar

Install

npm i ycatch

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • ramitos