npm.io
2.0.0 • Published 1 month ago

is-urlsearchparams

Licence
MIT
Version
2.0.0
Deps
2
Size
9 kB
Vulns
0
Weekly
0
Stars
2

is-urlsearchparams NPM Version File Size Build Status Coverage Status

Determine whether a value is a URLSearchParams instance.

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

If you need to support older versions of Node.js (going back to 8.x), use 1.x of this package.

Install

npm install is-urlsearchparams

Usage

Strict

The standard.

import isURLSearchParams from 'is-urlsearchparams';

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

Acceptance can be extended to incomplete URLSearchParams implementations that lack entries, sort and values methods (which is common with web browsers from 2021):

import isURLSearchParams from 'is-urlsearchparams/lenient';

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

isURLSearchParams(params); //-> true

Keywords