esnext.iterator.to-async.js 567 B

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