You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IterableToList.js 629B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var callBound = require('../helpers/callBound');
  3. var $arrayPush = callBound('Array.prototype.push');
  4. var GetIterator = require('./GetIterator');
  5. var IteratorStep = require('./IteratorStep');
  6. var IteratorValue = require('./IteratorValue');
  7. // https://www.ecma-international.org/ecma-262/8.0/#sec-iterabletolist
  8. module.exports = function IterableToList(items, method) {
  9. var iterator = GetIterator(items, method);
  10. var values = [];
  11. var next = true;
  12. while (next) {
  13. next = IteratorStep(iterator);
  14. if (next) {
  15. var nextValue = IteratorValue(next);
  16. $arrayPush(values, nextValue);
  17. }
  18. }
  19. return values;
  20. };