Skip to content

Commit a6ff640

Browse files
committed
Spec fixes
1 parent 704531a commit a6ff640

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

index.bs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,8 @@ The <dfn method for="Stream">from(input)</dfn> method creates an `AsyncIterable<
662662
<li>If |input| is a {{USVString}}, return an async iterable yielding a single batch containing the [=UTF-8 encode|UTF-8 encoded=] result.
663663
<li>If |input| is an {{ArrayBuffer}}, return an async iterable yielding a single batch containing a new {{Uint8Array}} wrapping |input| (zero-copy).
664664
<li>If |input| is an {{ArrayBufferView}}, return an async iterable yielding a single batch containing a {{Uint8Array}} view over the same buffer region (zero-copy).
665-
<li>If |input| has a method keyed by `Symbol.for('Stream.toAsyncStreamable')`, call that method and recursively normalize the result (awaiting if it returns a promise). This step takes precedence over the `toStreamable` protocol and the iteration protocols below. Implementations must guard against infinite recursion (e.g., an object whose protocol method returns itself); a {{TypeError}} should be thrown if a reasonable recursion depth is exceeded.
666-
<li>If |input| has a method keyed by `Symbol.for('Stream.toStreamable')`, call that method and recursively normalize the result. This step takes precedence over the iteration protocols below. The same recursion guard applies.
665+
<li>If |input| has a method keyed by `Symbol.for('Stream.toAsyncStreamable')`, call that method and recursively normalize the result (awaiting if it returns a promise). This step takes precedence over the `toStreamable` protocol and the iteration protocols below.
666+
<li>If |input| has a method keyed by `Symbol.for('Stream.toStreamable')`, call that method and recursively normalize the result. This step takes precedence over the iteration protocols below.
667667
<li>If |input| has a `Symbol.asyncIterator` method, return a new `AsyncIterable<Uint8Array[]>` that pulls from the resulting async iterator and normalizes each yielded value to a `Uint8Array[]` batch. Each yielded value is recursively normalized: strings are UTF-8 encoded; {{ArrayBuffer}} and {{ArrayBufferView}} values are converted to {{Uint8Array}}; arrays are flattened with each element normalized; nested iterables and async iterables are recursively consumed and flattened; objects with the `toStreamable` or `toAsyncStreamable` protocol are converted via that protocol. Values that are not convertible to {{Uint8Array}} cause a {{TypeError}}. Synchronous values encountered in sequence should be batched together into a single `Uint8Array[]` to maximize batching efficiency.
668668
<li>If |input| has a `Symbol.iterator` method, treat the sync iterator as an async source and normalize as in the previous step (except that nested async iterables and the `toAsyncStreamable` protocol are not supported and cause a {{TypeError}} during normalization).
669669
<li>Throw a {{TypeError}}.
@@ -676,7 +676,7 @@ Note: WHATWG `ReadableStream` objects implement `Symbol.asyncIterator` and are t
676676
--------------------------------------
677677

678678
<div algorithm>
679-
The <dfn method for="Stream">fromSync(input)</dfn> method creates an `Iterable<Uint8Array[]>` from synchronous input types. If |input| is `null` or `undefined`, it throws a {{TypeError}}. Otherwise it performs the same normalization as {{Stream/from()}} but only accepts synchronous inputs ({{USVString}}, {{ArrayBuffer}}, {{ArrayBufferView}}, objects with `Symbol.for('Stream.toStreamable')`, or objects with `Symbol.iterator`). Async inputs cause a {{TypeError}}.
679+
The <dfn method for="Stream">fromSync(input)</dfn> method creates an `Iterable<Uint8Array[]>` from synchronous input types. If |input| is `null` or `undefined`, it throws a {{TypeError}}. Otherwise it performs the same normalization as {{Stream/from()}} but only accepts synchronous inputs ({{USVString}}, {{ArrayBuffer}}, {{ArrayBufferView}}, objects with `Symbol.for('Stream.toStreamable')`, or objects with `Symbol.iterator`). The `toAsyncStreamable` protocol is ignored (not checked or rejected). Explicit async inputs are rejected with a {{TypeError}}: objects with `Symbol.asyncIterator` (and no synchronous interface), and `Promise` objects (even if the promise would resolve to a synchronous streamable type such as a string, {{Uint8Array}}, or iterable).
680680
</div>
681681

682682

0 commit comments

Comments
 (0)