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

Readme

Keywords

none

Package Sidebar

Install

npm i known-fetch-body

Weekly Downloads

7

Version

0.1.1

License

none

Last publish

Collaborators

  • fenfeizeng