npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

native-querystring

v1.1.1

Published

Node’s querystring module implemented using the built-in URLSeachParams API.

Readme

native-querystring

Build Status BrowserStack Status

Node’s querystring module implemented using the built-in URLSeachParams API.

:warning: Differences with original querystring module

  • Space and its percent-encoded value (%20) is replaced with plus-sign +
  • Fourth argument for parse and stringify is not supported

If you want to use Node’s url module based on the URL API, consider using native-url module.

Install

npm install native-querystring --save

Usage

import * as qs from 'querystring';

qs.parse('becky=1&jackson=brody&jackson=winnie'); // { becky: '1', jackson: ['brody', 'winnie'] }
qs.stringify({ becky: 1, gracie: ['rex', 'milo'], shadow: '' }); // becky=1&gracie=rex&gracie=milo&shadow=

If you want to alias querystring module to this module, refer to Webpack and Rollup documentation on aliasing modules (or, native-url alias explanation).

Usage with native-url, ES Modules and Webpack

Since native-url exposes ESM file through .mjs extension, additional Webpack configuration is needed to make native-url use ESM version of native-querystring.

{
	module: {
		rules: [
			{
				type: 'javascript/auto',
				test: /\.mjs$/,
				include: /node_modules\/native-url/,
				resolve: {
					mainFields: ['module']
				},
				use: []
			}
		];
	}
}

Named exports as default export

native-querystring (and native-url) expose their methods thorugh named exports. To get default behavior you would need to import entire module contents

import * as qs from 'native-querystring'; // or 'querystring' if aliased`
import * as url from 'native-url'; // or 'url' if aliased`

This is fine for your own code, but dependencies will throw error since they can’t find default export by default for both modules.

To fix this, it’s best to make changes to code at compile time to expose every named export as property of object which should be default export.

Here is a Babel plugin code which achieves that:

const babel = require('@babel/core');

const plugin = babel.createConfigItem(({ types: t }) => {
	return {
		visitor: {
			ExportNamedDeclaration(path, parent) {
				const properties = path.node.specifiers.map((node) => ({
					exported: node.exported.name,
					local: node.local.name
				}));
				path.insertAfter(
					t.exportDefaultDeclaration(
						t.objectExpression(
							properties.map((prop) =>
								t.objectProperty(
									t.identifier(prop.exported),
									t.identifier(prop.local)
								)
							)
						)
					)
				);
			}
		}
	};
});

And here is how you apply it with Webpack:

{
	test: /\.m?js$/,
	include: /node_modules\/(?:native-url|native-querystring)/,
	use: [
		{
			loader: 'babel-loader',
			options: {
				plugins: [plugin]
			}
		}
	]
};

After that you can use both modules’ named exports as default export.

API

parse(input, separator, equals)

Returns: Object

Parses a URL query string into a collection of key and value pairs.

| Property | Type | Default | Description | | ----------- | -------- | ------- | ---------------------------------------------------------------------- | | input | string | | The URL query string to parse. | | separator | string | & | The substring used to delimit key and value pairs in the query string. | | equals | string | = | The substring used to delimit keys and values in the query string. |

stringify(input, separator, equals)

Returns: string

Produces a URL query string from a given obj by iterating through the object's "own properties".

| Property | Type | Default | Description | | ----------- | -------- | ------- | ---------------------------------------------------------------------- | | input | Object | | The object to serialize into a URL query string. | | separator | string | & | The substring used to delimit key and value pairs in the query string. | | equals | string | = | The substring used to delimit keys and values in the query string. |

escape(input)

Returns: string

Performs URL percent-encoding on the given input in a manner that is optimized for the specific requirements of URL query strings.

input

Type: string

unescape(input)

Returns: string

Performs decoding of URL percent-encoded characters on the given input.

input

Type: string

Browser support

Tested in IE9+ and all modern browsers.

It relies on the DOM URLSearchParams API to work. For older browsers that don’t support the URLSearchParams API, a polyfill is available.

Test

Test suite is taken from Node core and querystring-es3 module to cover all native querystring test cases.

For automated tests, run npm run test:automated (append :watch for watcher support).

License

MIT © Ivan Nikolić