class DelimiterStream
Divide a stream into chunks delimited by a given byte sequence.
Examples
Divide a CSV stream by commas, discarding the commas:
Divide a CSV stream by commas, discarding the commas:
import { DelimiterStream } from "@std/streams/delimiter_stream"; const res = await fetch("https://example.com/data.csv"); const parts = res.body! .pipeThrough(new DelimiterStream(new TextEncoder().encode(","))) .pipeThrough(new TextDecoderStream());
Divide a stream after semi-colons, keeping the semi-colons in the output:
Divide a stream after semi-colons, keeping the semi-colons in the output:
import { DelimiterStream } from "@std/streams/delimiter_stream"; const res = await fetch("https://example.com/file.js"); const parts = res.body! .pipeThrough( new DelimiterStream( new TextEncoder().encode(";"), { disposition: "suffix" }, ) ) .pipeThrough(new TextDecoderStream());
Constructors
new DelimiterStream(delimiter: Uint8Array,options?: DelimiterStreamOptions)Constructs a new instance.