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 🙏

© 2024 – Pkg Stats / Ryan Hefner

query-string-handler

v3.1.1

Published

This turns the query string into a private object. Use the API to read and manipulate the query string.

Downloads

28

Readme

query-string-handler

This turns the query string into a private object. Use the API to read and manipulate the query string.

API

.update()

// only call this if an outside script updates the query string
queryStringHandler.update();

.setDefaults(obj)

@param obj {Object}

// When values equal the default value, they are ignored in the "toString"
queryStringHandler.setDefaults({ name: 'John Smith' });

.setTypes(obj)

@param obj {Object}

// Setting the type converts the query string value to that type
queryStringHandler.setTypes({ num: 'float' });

.getValue(name)

@param name {String}
@return {String}

// get a value from the query string
var val = queryStringHandler.getValue('name');

.toString([encoded[, params]])

@param encoded {Boolean}
@param params {Object}
@return {String}

// get the query string in string format
// optionally encode the ampersands with the first parameter
// optionally temporary extend the query string with the second parameter
// if all parameters are blank, it will return location.pathname
var url = queryStringHandler.toString(true, { beep: 'bop' });
console.log(url); // '?beep=bop'

.push(changes[, title])

@param changes {Object}
@param title {String}

// push a new state with changes to the query string
// optionally change the browser title
// emits an event with type 'pop'
queryStringHandler.push({ foo: 'bar' });

.replace(changes[, title])

@param changes {Object}
@param title {String}

// replace the state with changes to the query string
// optionally change the browser title
// emits an event with type 'replace'
queryStringHandler.replace({ foo: 'bar' });

.addListener(callback)

@param callback {Function}

// add a callback function to the stack
// all callbacks will be called on any event
// the first parameter in the callback will be the event type
queryStringHandler.addListener(function (type) {
    console.log(type);
});
history.back(); // 'pop'

.clone([obj])

@param obj {Object}
@return {Object}

// clone the private query string object
// optionally pass in an object to extend the query string
var clone = queryStringHandler.clone({ beep: 'boop' });

.clear(method = 'push'[, title])

@param method {String} replace|push
@param title {String}

// clone the private query string object
// optionally pass in an object to extend the query string
queryStringHandler.clear();

Install

npm install query-string-handler

Tests

Tests are written in qUnit. Open /example/index.html in a browser.

ES5 methods to polyfill

  • Object.keys
  • Array.forEach
  • Array.map
  • Array.filter

License

MIT © The C2 Group