JSPM

ycatch

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q34947F
  • License MIT

catch errors from generators, Go style

Package Exports

  • ycatch

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ycatch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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);