is-urlsearchparams

Determines whether a value is a URLSearchParams instance.

MIT 3 个版本
安装
npm install is-urlsearchparams
yarn add is-urlsearchparams
pnpm add is-urlsearchparams
bun add is-urlsearchparams
README

is-urlsearchparams NPM Version File Size Build Status Dependency Monitor

Determines whether a value is a URLSearchParams instance.

Works cross-realm/iframe and despite Symbol.toStringTag.

Installation

Node.js >= 8 is required. To install, type this at the command line:

npm install is-urlsearchparams

Usage

const isURLSearchParams = require('is-urlsearchparams');

isURLSearchParams('param=value');  //-> false
isURLSearchParams(new URLSearchParams('param=value'));  //-> true

Optionally, acceptance can be extended to incomplete URLSearchParams implementations that lack entries, sort and values methods (which are common in many modern web browsers):

const params = new URLSearchParams('param=value');

console.log(params.sort);  //-> undefined

isURLSearchParams.lenient(params);  //-> true
版本列表
1.0.2 2021-02-27
1.0.1 2019-04-22
1.0.0 2019-01-06