esnext.iterator.to-array.js 496 B

12345678910111213141516
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var iterate = require('../internals/iterate');
  4. var getIteratorDirect = require('../internals/get-iterator-direct');
  5. var push = [].push;
  6. // `Iterator.prototype.toArray` method
  7. // https://github.com/tc39/proposal-iterator-helpers
  8. $({ target: 'Iterator', proto: true, real: true }, {
  9. toArray: function toArray() {
  10. var result = [];
  11. iterate(getIteratorDirect(this), push, { that: result, IS_RECORD: true });
  12. return result;
  13. }
  14. });