esnext.iterator.to-async.js 691 B

123456789101112131415
  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. var IS_PURE = require('../internals/is-pure');
  8. // `Iterator.prototype.toAsync` method
  9. // https://github.com/tc39/proposal-async-iterator-helpers
  10. $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
  11. toAsync: function toAsync() {
  12. return new WrapAsyncIterator(getIteratorDirect(new AsyncFromSyncIterator(getIteratorDirect(anObject(this)))));
  13. }
  14. });