main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
721 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var callBound = require('call-bind/callBound');
|
---|
4 | var $arrayPush = callBound('Array.prototype.push');
|
---|
5 |
|
---|
6 | var GetIterator = require('./GetIterator');
|
---|
7 | var IteratorStep = require('./IteratorStep');
|
---|
8 | var IteratorValue = require('./IteratorValue');
|
---|
9 |
|
---|
10 | // https://262.ecma-international.org/12.0/#sec-iterabletolist
|
---|
11 |
|
---|
12 | module.exports = function IterableToList(items) {
|
---|
13 | var iterator;
|
---|
14 | if (arguments.length > 1) {
|
---|
15 | iterator = GetIterator(items, 'sync', arguments[1]);
|
---|
16 | } else {
|
---|
17 | iterator = GetIterator(items, 'sync');
|
---|
18 | }
|
---|
19 | var values = [];
|
---|
20 | var next = true;
|
---|
21 | while (next) {
|
---|
22 | next = IteratorStep(iterator);
|
---|
23 | if (next) {
|
---|
24 | var nextValue = IteratorValue(next);
|
---|
25 | $arrayPush(values, nextValue);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | return values;
|
---|
29 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.