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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.113latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.113
0.1.00

Package Sidebar

Install

npm i known-fetch-body

Weekly Downloads

13

Version

0.1.1

License

none

Last publish

Collaborators

  • fenfeizeng