mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
Promise.all, allSettled, any and race threw synchronously when their
argument was not iterable or iterating it failed; like the reference they
now return a promise rejected with that error, and word the non-iterable
case as the reference does ('Promise.all expects a synchronous iterable,
received a number.').
GetIterator now uses the reference's messages for a Symbol.iterator that is
not a function or returns a non-object, in every place that iterates.
Touches ops.rs (get_iterator, get_async_iterator).
70 test262 files leave rust-skipped.txt.
10 lines
505 B
JavaScript
10 lines
505 B
JavaScript
const out = []
|
|
for (const b of [{ [Symbol.iterator]: () => 1 }, { [Symbol.iterator]: 5 }, "ab"]) {
|
|
try { for (const x of b) out.push(x) } catch (e) { out.push(e.message) }
|
|
try { out.push([...b].length) } catch (e) { out.push(e.message) }
|
|
try { out.push(Array.from(b).length) } catch (e) { out.push(e.message) }
|
|
try { const [x] = b; out.push(x) } catch (e) { out.push(e.message) }
|
|
try { out.push(new Set(b).size) } catch (e) { out.push(e.message) }
|
|
}
|
|
out.push(await Promise.all("ab"))
|
|
return out
|