known-fetch-body
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Detect fetch API body type

Detect the type of a variable is the known request body type of browser fetch API and node-fetch. Currently known types are string, FormData, Blob, URLSearchParams, Buffer, stream.Readable.

Install

npm install known-fetch-body

Quick Start

import isKnownReqBodyType from "known-fetch-body";
import {createReadStream} from "stream";

isKnownReqBodyType("string");   // true
isKnownReqBodyType(new FormData()); // true
isKnownReqBodyType(new URLSearchParams());  // true
isKnownReqBodyType(new Buffer());   // true
isKnownReqBodyType(createReadStream("filePath"));    // true
isKnownReqBodyType({}); // false

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i known-fetch-body

    Weekly Downloads

    4

    Version

    0.1.1

    License

    none

    Last publish

    Collaborators

    • fenfeizeng