es.iterator.to-array.js 562 B

1234567891011121314151617
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var anObject = require('../internals/an-object');
  4. var iterate = require('../internals/iterate');
  5. var getIteratorDirect = require('../internals/get-iterator-direct');
  6. var push = [].push;
  7. // `Iterator.prototype.toArray` method
  8. // https://tc39.es/ecma262/#sec-iterator.prototype.toarray
  9. $({ target: 'Iterator', proto: true, real: true }, {
  10. toArray: function toArray() {
  11. var result = [];
  12. iterate(getIteratorDirect(anObject(this)), push, { that: result, IS_RECORD: true });
  13. return result;
  14. }
  15. });