• Download a resource to the filesystem using fetch and fs.createWriteStream, default method is GET

    Parameters

    • url: string
    • file: PathLike
    • Optional options: RequestInit

    Returns Promise<number>

    Time it took to download in ms

    Example

    import { network } from "@rjweb/utils"

    await network.download('http://speedtest.belwue.net/random-1G', '/tmp/1gb.test') // 14314.149778962135

    Since

    1.8.5

    Supports

    nodejs