source: imaps-frontend/node_modules/es-abstract/2016/IterableToArrayLike.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3var callBound = require('call-bind/callBound');
4var $arrayPush = callBound('Array.prototype.push');
5
6var getIteratorMethod = require('../helpers/getIteratorMethod');
7var AdvanceStringIndex = require('./AdvanceStringIndex');
8var GetIterator = require('./GetIterator');
9var GetMethod = require('./GetMethod');
10var IsArray = require('./IsArray');
11var IteratorStep = require('./IteratorStep');
12var IteratorValue = require('./IteratorValue');
13var ToObject = require('./ToObject');
14var ES = {
15 AdvanceStringIndex: AdvanceStringIndex,
16 GetMethod: GetMethod,
17 IsArray: IsArray
18};
19
20// https://262.ecma-international.org/7.0/#sec-iterabletoarraylike
21
22module.exports = function IterableToArrayLike(items) {
23 var usingIterator = getIteratorMethod(ES, items);
24 if (typeof usingIterator !== 'undefined') {
25 var iterator = GetIterator(items, usingIterator);
26 var values = [];
27 var next = true;
28 while (next) {
29 next = IteratorStep(iterator);
30 if (next) {
31 var nextValue = IteratorValue(next);
32 $arrayPush(values, nextValue);
33 }
34 }
35 return values;
36 }
37
38 return ToObject(items);
39};
Note: See TracBrowser for help on using the repository browser.