New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@herberthe/fetch-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@herberthe/fetch-stream

A JavaScript library for fetching stream data.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

fetch-stream

version download

A JavaScript library for fetching stream data.

Install

npm install @herberthe/fetch-stream

Usage

import { FetchStream } from "@herberthe/fetch-stream"
const fetchStream = new FetchStream({
    preset: "text",
    timeout: 5000,
    onProcess: (val) => {
        document.getElementById(
            "content"
        ).innerHTML += `<div>${val}<div>`
    },
    onDone: () => {
        console.log("Done!")
    },
    onError: (err) => {
        alert(err)
    },
})

fetchStream.createFetchRequest("/mock")

Options

OptionRequiredTypeDefaultDescription
presetNo"text"undefinedpreset decoder
timeoutNonumber or -1undefinedtimeout in milliseconds(if the value is -1, it means no timeout)
decoderNo<T>(value?: Uint8Array) => Tundefinedcustom decoder
onProcessNo(value: T) => voidundefinedcallback function for processing each chunk of data
onDoneNo() => voidundefinedcallback function when all data is processed
onErrorNo(error: Error) => voidundefinedcallback function when an error occurs
onAbortNo() => voidundefinedcallback function when the request is aborted
onTimeoutNo() => voidundefinedcallback function when the request times out

Methods

MethodDescription
createFetchRequest(url: string, options?: RequestInit)create a fetch request
abort()abort the fetch request

License

MIT © Herbert He

Keywords

fetch

FAQs

Package last updated on 05 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts