| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cf88ed8 commit b2fb01a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,8 @@ function from(Readable, iterable, opts) { | |||
| 33 | 33 | ||
| 34 | 34 | const readable = new Readable({ | |
| 35 | 35 | objectMode: true, | |
| 36 | + highWaterMark: 1, | ||
| 37 | + // TODO(ronag): What options should be allowed? | ||
| 36 | 38 | ...opts | |
| 37 | 39 | }); | |
| 38 | 40 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,6 +159,29 @@ async function asTransformStream() { | |||
| 159 | 159 | } | |
| 160 | 160 | } | |
| 161 | 161 | ||
| 162 | + async function endWithError() { | ||
| 163 | + async function* generate() { | ||
| 164 | + yield 1; | ||
| 165 | + yield 2; | ||
| 166 | + yield Promise.reject('Boum'); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + const stream = Readable.from(generate()); | ||
| 170 | + | ||
| 171 | + const expected = [1, 2]; | ||
| 172 | + | ||
| 173 | + try { | ||
| 174 | + for await (const chunk of stream) { | ||
| 175 | + strictEqual(chunk, expected.shift()); | ||
| 176 | + } | ||
| 177 | + throw new Error(); | ||
| 178 | + } catch (err) { | ||
| 179 | + strictEqual(expected.length, 0); | ||
| 180 | + strictEqual(err, 'Boum'); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + | ||
| 162 | 185 | Promise.all([ | |
| 163 | 186 | toReadableBasicSupport(), | |
| 164 | 187 | toReadableSyncIterator(), | |
@@ -168,5 +191,6 @@ Promise.all([ | |||
| 168 | 191 | toReadableOnData(), | |
| 169 | 192 | toReadableOnDataNonObject(), | |
| 170 | 193 | destroysTheStreamWhenThrowing(), | |
| 171 | - asTransformStream() | ||
| 194 | + asTransformStream(), | ||
| 195 | + endWithError() | ||
| 172 | 196 | ]).then(mustCall()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments