convert a string/Buffer/Uint8Array to a readable stream, support highWaterMark and adjustable push delay
npm i buffer-readable
import { BufferReadable } from "buffer-readable";
const stream = new BufferReadable("hello", { highWaterMark: 1, delay: 1000 });
for await (const chunk of stream) {
// do sth
}
new BufferReadable(buffer: string | Uint8Array | Buffer, opts?: BufferReadableOptions): BufferReadable
buffer
: string | Uint8Array | Bufferopts
(Optional) : BufferReadableOptions
-
delay
(Optional) : numberDelayed push, in milliseconds
MIT