get-async-iterator.js 723 B

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