get-async-iterator.js 635 B

12345678910111213
  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 getMethod = require('../internals/get-method');
  6. var wellKnownSymbol = require('../internals/well-known-symbol');
  7. var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');
  8. module.exports = function (it, usingIterator) {
  9. var method = arguments.length < 2 ? getMethod(it, ASYNC_ITERATOR) : usingIterator;
  10. return method ? anObject(call(method, it)) : new AsyncFromSyncIterator(getIterator(it));
  11. };