get-async-iterator.js 737 B

123456789101112131415
  1. 'use strict';
  2. var call = require('../internals/function-call');
  3. var AsyncFromSyncIterator = require('../internals/async-from-sync-iterator');
  4. var anObject = require('../internals/an-object');
  5. var getIterator = require('../internals/get-iterator');
  6. var getIteratorDirect = require('../internals/get-iterator-direct');
  7. var getMethod = require('../internals/get-method');
  8. var wellKnownSymbol = require('../internals/well-known-symbol');
  9. var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');
  10. module.exports = function (it, usingIterator) {
  11. var method = arguments.length < 2 ? getMethod(it, ASYNC_ITERATOR) : usingIterator;
  12. return method ? anObject(call(method, it)) : new AsyncFromSyncIterator(getIteratorDirect(getIterator(it)));
  13. };