On 1/23/2014 4:46 PM, Domenic Denicola wrote:
Task.js is still on "JavaScript 1.8," and is not ES6-compatible. It won't work 
with modern browsers, or with Regenerator.

For most uses, Task.js's Task.spawn can be replaced with a smaller helper function:

```js
function spawn(thunk) {
  return new Promise(function(resolve, reject) {
    var gen = thunk();

    function _next(v) {
      return handle(gen.next(v));
    }

    function _throw(e) {
      return handle(gen.throw(e));
    }

    function handle(r) {
      return r.done ? r.value : Promise.cast(r.value).then(_next, _throw);
    }

    Promise.cast(_next()).then(resolve, reject);
  });
}
```
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to