| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 707f6ea commit 136d4e7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,6 +504,7 @@ function* withFlushSync(source) { | |||
| 504 | 504 | function* applyStatefulSyncTransform(source, transform) { | |
| 505 | 505 | const output = transform(withFlushSync(source)); | |
| 506 | 506 | for (const item of output) { | |
| 507 | + if (item === null) continue; | ||
| 507 | 508 | const batch = []; | |
| 508 | 509 | for (const chunk of flattenTransformYieldSync(item)) { | |
| 509 | 510 | ArrayPrototypePush(batch, chunk); | |
@@ -643,6 +644,7 @@ async function* withFlushAsync(source) { | |||
| 643 | 644 | async function* applyStatefulAsyncTransform(source, transform, options) { | |
| 644 | 645 | const output = transform(withFlushAsync(source), options); | |
| 645 | 646 | for await (const item of output) { | |
| 647 | + if (item === null) continue; | ||
| 646 | 648 | // Fast path: item is already a Uint8Array[] batch (e.g. compression transforms) | |
| 647 | 649 | if (isUint8ArrayBatch(item)) { | |
| 648 | 650 | if (item.length > 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,28 @@ async function testStatefulSyncTransformYieldsString() { | |||
| 142 | 142 | assert.deepStrictEqual(data, new TextEncoder().encode('world')); | |
| 143 | 143 | } | |
| 144 | 144 | ||
| 145 | + // Stateful async transform yields null (no output) | ||
| 146 | + async function testStatefulTransformYieldsNull() { | ||
| 147 | + const tx = { | ||
| 148 | + async *transform() { | ||
| 149 | + yield null; | ||
| 150 | + }, | ||
| 151 | + }; | ||
| 152 | + const data = await bytes(pull(from('x'), tx)); | ||
| 153 | + assert.deepStrictEqual(data, new Uint8Array()); | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + // Stateful sync transform yields null (no output) | ||
| 157 | + async function testStatefulSyncTransformYieldsNull() { | ||
| 158 | + const tx = { | ||
| 159 | + *transform() { | ||
| 160 | + yield null; | ||
| 161 | + }, | ||
| 162 | + }; | ||
| 163 | + const data = bytesSync(pullSync(fromSync('x'), tx)); | ||
| 164 | + assert.deepStrictEqual(data, new Uint8Array()); | ||
| 165 | + } | ||
| 166 | + | ||
| 145 | 167 | // Flush returns single Uint8Array (not batch) | |
| 146 | 168 | async function testFlushReturnsSingleUint8Array() { | |
| 147 | 169 | const tx = (chunks) => { | |
@@ -217,6 +239,8 @@ Promise.all([ | |||
| 217 | 239 | testStatefulTransformYieldsString(), | |
| 218 | 240 | testStatefulTransformYieldsArrayBuffer(), | |
| 219 | 241 | testStatefulSyncTransformYieldsString(), | |
| 242 | + testStatefulTransformYieldsNull(), | ||
| 243 | + testStatefulSyncTransformYieldsNull(), | ||
| 220 | 244 | testFlushReturnsSingleUint8Array(), | |
| 221 | 245 | testFlushReturnsString(), | |
| 222 | 246 | testSyncFlushReturnsSingleUint8Array(), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments