lib/index.js
function starx(obj) {
    if (!isGenerator(obj) && !isIterator(obj)) throw new TypeError('obj must be a generator or iterator')

    return function executor(done) {
      var self = this,
          done = once(done || noop),
          iterator = isGenerator(obj) ? obj.call(self) : obj

      process.nextTick(next)
      function next(err, value) {    
        var res, _next = once(next)

        domain.create()
          // iterator throws, we're done
          .on('error', done)
          .run(function() {
            res = err ? iterator.throw(err) : iterator.next(value)
          })
      
        domain.create()
          // yieldable throws, iterator is certainly not yet exhausted, so run next
          .on('error', _next)
          .run(function() {
            wrap.call(self, res.value).call(self, function cb() {
              (res.done ? done : _next).apply(null, arguments)
            })
          })
      }
    }
  }
function starx(obj) {
    if (!isGenerator(obj) && !isIterator(obj)) throw new TypeError('obj must be a generator or iterator')

    return function executor(done) {
      var self = this,
          done = once(done || noop),
          iterator = isGenerator(obj) ? obj.call(self) : obj

      process.nextTick(next)
      function next(err, value) {    
        var res, _next = once(next)

        domain.create()
          // iterator throws, we're done
          .on('error', done)
          .run(function() {
            res = err ? iterator.throw(err) : iterator.next(value)
          })
      
        domain.create()
          // yieldable throws, iterator is certainly not yet exhausted, so run next
          .on('error', _next)
          .run(function() {
            wrap.call(self, res.value).call(self, function cb() {
              (res.done ? done : _next).apply(null, arguments)
            })
          })
      }
    }
  }
function starx ( obj ) { if ( ! isGenerator ( obj ) && ! isIterator ( obj ) ) throw new TypeError ( 'obj must be a generator or iterator' ) return function executor ( done ) { var self = this , done = once ( done || noop ) , iterator = isGenerator ( obj ) ? obj . call ( self ) : obj process . nextTick ( next ) function next ( err , value ) { var res , _next = once ( next ) domain . create ( ) // iterator throws, we're done . on ( 'error' , done ) . run ( function ( ) { res = err ? iterator . throw ( err ) : iterator . next ( value ) } ) domain . create ( ) // yieldable throws, iterator is certainly not yet exhausted, so run next . on ( 'error' , _next ) . run ( function ( ) { wrap . call ( self , res . value ) . call ( self , function cb ( ) { ( res . done ? done : _next ) . apply ( null , arguments ) } ) } ) } } }
Creates an executor for the provided generator or iterator
Creates an executor for the provided generator or iterator