• Stream a Resource Chunk by Chunk

    Parameters

    • url: string
    • Optional options: RequestInit

    Returns AsyncIterable<Uint8Array> & {
        text(): AsyncIterable<string, any, any>;
    }

    Example

    import { network } from "@rjweb/utils"

    const decoder = new TextDecoder()
    for await (const chunk of network.stream('https://google.com')) {
    process.stdout.write(decoder.decode(chunk))
    }

    for await (const chunk of network.stream('https://google.com').text()) {
    process.stdout.write(chunk)
    }

    Since

    1.9.0

    Supports

    nodejs, browser