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

@zakkudo/query-string

v1.0.0

Published

Make working with url query-strings enjoyable.

Downloads

22

Readme

@zakkudo/query-string

Make working with url query-strings enjoyable.

Build Status Coverage Status Known Vulnerabilities Node License

Why use this?

  • Consistancy with simplicity
  • The instance acts like a plain-old-object
  • JSON.stringify() will serialize it to json like it was a normal object
  • Casting to a string will format it to be directly usable in a query Update the properties after initialization and the serialization will reflect the updates
  • Complex params are automatically serialized and deserialized from json

Install

# Install using npm
npm install @zakkudo/query-string
# Install using yarn
yarn add @zakkudo/query-string

Examples

Initializing with an object

import QueryString from '@zakkudo/query-string';

const query = new QueryString({
  page: 3,
  title: 'awesomeness',
  complex: {'test': 'value'}
});

String(query) // '?page=3&title=awesomeness&complex=%7B%22test%22%3A%22value%22%7D&'
query.toString() // '?page=3&title=awesomeness&complex=%7B%22test%22%3A%22value%22%7D&'

const url = `http://example${query}` //Automatically serializes correctly

const url = `http://example${query}` //Automatically serializes correctly with changes

Initializing with a URL and making changes dynamically

import QueryString from '@zakkudo/query-string';

const query = new QueryString('http://example?page=3&title=awesomeness');

delete query.page;

String(query) // '?title=awesomeness'
query.toString() // '?title=awesomeness'

Error handling

import QueryString from '@zakkudo/query-string';
import QueryStringError from '@zakkudo/query-string/QueryStringError';

try {
    const query = new QueryString('http://invalid.com/?first=1?second=2')
} catch(e) {
    if (e instanceof QueryStringError) {
        console.error(e.message); // Trying to add duplicate query param when already exists
    } else {
        throw e;
    }
}

API

@zakkudo/query-string~QueryString ⏏

Kind: Exported class

new QueryString([data], [options])

Throws:

| Param | Type | Default | Description | | --- | --- | --- | --- | | [data] | String | Object | QueryString | | Initial data. A url String will be parsed, and Object/QueryString instances will be copied. | | [options] | Object | | Modifiers for how the query string object is contructed | | [options.unsafe] | Boolean | false | Disable url escaping of key/value pairs. Useful for servers that use unsafe characters as delimiters |

@zakkudo/query-string/QueryStringError~QueryStringError ⇐ Error

Error class used by QueryString for raising errors generated during parsing or serialization.

Kind: Exported class

Extends: Error

new QueryStringError(message, url)

| Param | Type | Description | | --- | --- | --- | | message | String | A message describing the reason for the error. | | url | String | The related url fragment when the error was generated |

queryStringError.url

The related url fragment when the error was generated

Kind: instance property of QueryStringError