esnext.iterator.to-array.js 471 B

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