esnext.iterator.to-async.js 536 B

123456789101112
  1. 'use strict';
  2. // https://github.com/tc39/proposal-iterator-helpers
  3. var $ = require('../internals/export');
  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. $({ target: 'Iterator', proto: true, real: true, forced: true }, {
  8. toAsync: function toAsync() {
  9. return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(this))));
  10. }
  11. });