Ethan Arrowood
9e6dd49a12
stream: add dump()/dumpSync() for stream/iter
...
Every consumer in node:stream/iter retains what it reads, so there is
no way to read a streamable to completion while keeping nothing. To
clear a stream, callers write `for await (const _ of source) {}`. This
is apparent throughout multiple test suites, including the stream/iter
tests themselves.
These are especially useful for QUIC where a receiver doesn't want the
payload, but still has to read it to completion to relieve
backpressure. bytes() does that too, but allocates the whole payload to
discard it.
dump() pulls every batch and drops it, so peak memory is one batch
regardless of volume. It takes the same signal and limit options as
the other consumers, rejects if the source errors mid-stream, and
fulfills with undefined. dumpSync() is the synchronous form.
The name follows undici's body.dump(). drain() was the obvious
alternative but this module already exports ondrain() and
drainableProtocol() for writer-side backpressure, which is the
opposite side of the pipe.
Assisted-by: Claude Opus 5
Signed-off-by: Ethan Arrowood <ethan@arrowood.dev >
PR-URL: https://github.com/nodejs/node/pull/65598
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Tim Perry <pimterry@gmail.com >
2026-10-07 20:01:29 +00:00
Dayun
31e841f056
stream: fix pipeline function tail deadlock
...
Signed-off-by: Dayun <dlekdbs6530@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/65559
Fixes: https://github.com/nodejs/node/issues/40685
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-09-26 19:32:45 +00:00
Matteo Collina
4d27d802e6
stream: expose ReadableStreamTee
...
Signed-off-by: Matteo Collina <hello@matteocollina.com >
PR-URL: https://github.com/nodejs/node/pull/64195
Refs: https://github.com/nodejs/undici/issues/5358
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-07-05 08:04:44 +00:00
James M Snell
500c3a53e3
stream: add stream/iter to classic stream adapters
...
Signed-off-by: James M Snell <jasnell@gmail.com >
Assisted-by: Opencode/Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62469
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2026-04-06 09:59:56 -07:00
James M Snell
ae7c6a7767
stream: add stream/iter Implementation
...
Experimental implementation of https://stream-iter.jasnell.me/
Signed-off-by: James M Snell <jasnell@gmail.com >
Assisted-By: Claude/Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62066
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2026-03-27 19:55:08 -07:00
wantaek
938f175dbe
stream: add bytes() method to stream/consumers
...
- Add bytes() method to get Uint8Array from streams
- Add tests for bytes() method in PassThrough and ObjectMode scenarios
- Update documentation
Fixes: https://github.com/nodejs/node/issues/59542
PR-URL: https://github.com/nodejs/node/pull/60426
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
2026-01-29 13:24:39 +00:00
Debadree Chatterjee
23effb255e
stream: add pipeline() for webstreams
...
Refs: https://github.com/nodejs/node/issues/39316
PR-URL: https://github.com/nodejs/node/pull/46307
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-02-02 19:45:42 +00:00
Erick Wendel
5d0946ad0e
stream: fix readable stream as async iterator function
...
Since v19.2 it's not possible to use readableStreams
as async iterators (confirmed bug).
This patch fixes the problem by reading the Stream.Duplex property
from 'streams/duplex' instead of 'streams/legacy' module
Fixes: https://github.com/nodejs/node/issues/46141
PR-URL: https://github.com/nodejs/node/pull/46147
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-01-20 12:37:52 +00:00
Benjamin Gruenbaum
d2ac192351
stream: add reduce
...
PR-URL: https://github.com/nodejs/node/pull/41669
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2022-01-30 14:07:32 +00:00
James M Snell
94de738aa4
stream: remove whatwg streams experimental warning
...
The API is still experimental, but the warning isn't necessary any
longer
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/40971
Refs: https://github.com/nodejs/node/issues/40950
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2021-12-01 08:02:13 +00:00
Robert Nagy
8ee4e672ec
stream: pipeline with end option
...
Currently pipeline cannot fully replace pipe due
to the missing end option. This PR adds the end
option to the promisified pipeline method.
PR-URL: https://github.com/nodejs/node/pull/40886
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-11-22 10:52:23 +01:00
Robert Nagy
c04d621ecc
stream: add signal support to pipeline generators
...
Generators in pipeline must be able to be aborted or pipeline
can deadlock.
PR-URL: https://github.com/nodejs/node/pull/39067
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-08-25 17:44:28 +02:00
James M Snell
ca19775d0e
stream: ensure text() stream consumer flushes correctly
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39737
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-08-13 15:16:48 -07:00
James M Snell
c52410710e
stream: utility consumers for web and node.js streams
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39594
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-08-06 15:42:58 -07:00
James M Snell
09ad64d66d
stream: add CompressionStream and DecompressionStream
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39348
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-07-14 10:52:59 -07:00
James M Snell
25e2f177cb
stream: implement TextEncoderStream and TextDecoderStream
...
Experimental as part of the web streams implementation
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39347
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-07-14 09:12:43 -07:00
Robert Nagy
bb275ef2a4
stream: unify stream utils
...
Unify stream helps into utils.
PR-URL: https://github.com/nodejs/node/pull/39294
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-07-11 10:40:30 +02:00
James M Snell
fa0c6883a6
stream: implement WHATWG streams
...
Experimental implementation of the WHATWG streams standard.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39062
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-06-30 12:54:41 -07:00
Joyee Cheung
a4ea9fc48e
lib: remove unnecessary lazy loads
...
Now that more modules are included in the snapshot, it's not
necessary to lazy load them anymore
PR-URL: https://github.com/nodejs/node/pull/38737
Refs: https://github.com/nodejs/node/issues/35711
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-05-27 21:46:48 +08:00
Rich Trott
1e34df139c
stream: move duplicated code to an internal module
...
Create a utils module for isIterable(), isReadable(), and isStream().
PR-URL: https://github.com/nodejs/node/pull/37508
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-02-28 05:07:26 -08:00
Nitzan Uziely
38f6e5a789
stream: add AbortSignal to promisified pipeline
...
add support for AbortSignal to promisified pipeline.
Resolves: https://github.com/nodejs/node/issues/37321
PR-URL: https://github.com/nodejs/node/pull/37359
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com >
2021-02-18 18:00:02 +02:00
rickyes
527e2147af
stream: add promises version to utility functions
...
PR-URL: https://github.com/nodejs/node/pull/33991
Fixes: https://github.com/nodejs/node/issues/33582
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2020-07-09 09:12:19 +02:00