esnext.iterator.to-async.js 641 B

1234567891011121314
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var anObject = require('../internals/an-object');
  4. var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
  5. var WrapAsyncIterator = require('../internals/async-iterator-wrap');
  6. var getIteratorDirect = require('../internals/get-iterator-direct');
  7. // `Iterator.prototype.toAsync` method
  8. // https://github.com/tc39/proposal-async-iterator-helpers
  9. $({ target: 'Iterator', proto: true, real: true, forced: true }, {
  10. toAsync: function toAsync() {
  11. return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this)))));
  12. }
  13. });