known-fetch-body
v0.1.1
Published
Detect if the type of an argument is supported by the request body of browser fetch api and node-fetch.
Downloads
47
Readme
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