Skip to content

Commit 254f7b0

Browse files
docs: clarify when the sequence init runs IteratorClose
Comment-only. The previous wording ("on either abrupt completion") could be read as closing the iterator on any failure, including a throw from next() itself. Spelled out the actual rule: conversion failures and wrong-length pairs close the source iterator, while a throw from the stepping (next(), or reading the result's done/value) does not, because the ES iterator protocol marks the iterator done on such a throw and IteratorClose is skipped for a done iterator.
1 parent dfcce8c commit 254f7b0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test-app/runtime/src/main/cpp/URLSearchParamsImpl.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,12 @@ namespace tns {
399399
// by the caller) and append each [name, value] pair. Covers Array, Map, Set,
400400
// another URLSearchParams and generators uniformly. A pair whose length is
401401
// not exactly 2 throws a TypeError; a name/value that cannot be coerced to a
402-
// string aborts with the JS exception left pending. On either abrupt
403-
// completion the source iterator is closed first (ES IteratorClose).
402+
// string aborts with the JS exception left pending. On either of those two
403+
// failures the source iterator is closed first (ES IteratorClose). A throw
404+
// from the stepping itself (next(), or reading the result's done/value)
405+
// intentionally does NOT close the iterator: the ES iterator protocol marks
406+
// the iterator done on such a throw (IteratorStepValue), and IteratorClose
407+
// is skipped for a done iterator, which is also how for..of behaves.
404408
bool BuildFromSequence(v8::Local<v8::Context> context, v8::Local<v8::Object> object,
405409
v8::Local<v8::Function> iterMethod, ada::url_search_params &params) {
406410
auto isolate = context->GetIsolate();

0 commit comments

Comments
 (0)