DeflateRaw.compose method | Node.js zlib module | Bun
BuildDocsReferenceGuidesBlogDiscord/
node:zlib/
DeflateRaw/
composeMcompose
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
node:zlib/
DeflateRaw/
composeMcompose
method
zlib.DeflateRaw.composecompose(stream: WritableStream |
WritableStreamany> |
TransformStreamany, any> | (source: any) => void,options?:
Abortable):
Duplex;
import { Readable } from 'node:stream';
async function* splitToWords(source) {
for await (const chunk of source) {
const words = String(chunk).split(' ');
for (const word of words) {
yield word;
}
}
}
const wordsStream = Readable.from(['text passed through', 'composed stream']).compose(splitToWords);
const words = await wordsStream.toArray();
console.log(words); // prints ['text', 'passed', 'through', 'composed', 'stream']
readable.compose(s) is equivalent to stream.compose(readable, s).
This method also allows for an AbortSignal to be provided, which will destroy the composed stream when aborted.
See stream.compose(...streams) for more information.
@returns
a stream composed with the stream stream.
Referenced typesinterface
WritableStreamW = any>readonly
locked: boolean
abort(reason?: any): Promisevoid>;
close(): Promisevoid>;
getWriter():
WritableStreamDefaultWriterW>;interface
TransformStreamI = any, O = any>readonly
readable:
ReadableStreamO>readonly
writable:
WritableStreamI>
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →