Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 773 Bytes

README.md

File metadata and controls

33 lines (25 loc) · 773 Bytes

StreamConv

Node.js stream to Web stream and vice versa.

Example

Web streams to node stream

import Converter from "https://deno.land/x/streamconv/mod.ts";

const res = await fetch("https://mysite.com");

if (res.body) {
    const stream = Converter.WebToReadable(res.body); // Readable stream instance
    stream.on("data", chunk => console.log(chunk.toString()));
} else {
    console.log("no stream");
}

Node stream to web stream

import Converter from "https://deno.land/x/streamconv/mod.ts";

const res = await fetch("https://mysite.com");

if (res.body) {
    const stream = Converter.WebToReadable(res.body);
    const webstream = Converter.ReadableToWeb(stream); // web ReadableStream instance
} else {
    console.log("no stream");
}