supports-iterator.js (549B)
1 // Copyright (C) 2023 Michael Ficarra. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-iterator.from 5 description: > 6 Iterator.from supports non-iterable iterators 7 info: | 8 Iterator.from ( O ) 9 10 includes: [compareArray.js] 11 features: [iterator-helpers] 12 flags: [] 13 ---*/ 14 15 function* g() { 16 yield 0; 17 yield 1; 18 yield 2; 19 yield 3; 20 } 21 22 let n = g(); 23 let iter = { 24 next() { 25 return n.next(); 26 }, 27 }; 28 29 assert.compareArray(Array.from(Iterator.from(iter)), [0, 1, 2, 3]); 30 31 reportCompare(0, 0);