esnext.async-iterator.from.js 704 B

123456789101112131415
  1. // https://github.com/tc39/proposal-iterator-helpers
  2. var $ = require('../internals/export');
  3. var isPrototypeOf = require('../internals/object-is-prototype-of');
  4. var getAsyncIteratorFlattenable = require('../internals/get-async-iterator-flattenable');
  5. var AsyncIteratorPrototype = require('../internals/async-iterator-prototype');
  6. var WrapAsyncIterator = require('../internals/async-iterator-wrap');
  7. $({ target: 'AsyncIterator', stat: true, forced: true }, {
  8. from: function from(O) {
  9. var iteratorRecord = getAsyncIteratorFlattenable(O);
  10. return isPrototypeOf(AsyncIteratorPrototype, iteratorRecord.iterator)
  11. ? iteratorRecord.iterator
  12. : new WrapAsyncIterator(iteratorRecord);
  13. }
  14. });