GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: make from read one at a time · nodejs/node@b2fb01a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams
    • from.js
  • test/parallel
    • test-readable-from.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/from.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/from.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ function from(Readable, iterable, opts) {
3333

3434
const readable = new Readable({
3535
objectMode: true,
36+
highWaterMark: 1,
37+
// TODO(ronag): What options should be allowed?
3638
...opts
3739
});
3840

Collapse file

‎test/parallel/test-readable-from.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-readable-from.js
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,29 @@ async function asTransformStream() {
159159
}
160160
}
161161

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+
162185
Promise.all([
163186
toReadableBasicSupport(),
164187
toReadableSyncIterator(),
@@ -168,5 +191,6 @@ Promise.all([
168191
toReadableOnData(),
169192
toReadableOnDataNonObject(),
170193
destroysTheStreamWhenThrowing(),
171-
asTransformStream()
194+
asTransformStream(),
195+
endWithError()
172196
]).then(mustCall());

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.