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

parameters-js

v1.0.33

Published

Simply manage url parameters.

Downloads

26

Readme

Parameters JS 🔑

npm version Maintainability

Simply manage url parameters.

Install

npm install parameters-js

Usage

var Parameters = require('parameters-js');

var parameters = new Parameters();

parameters.post = 2;
parameters.string;
// => "post=2"

parameters.date = '10/12/1997';
parameters.string;
// => "post=2&date=10%2F12%2F1997"

parameters.authors = [
    {name: 'Marie', country: 'England'},
    {name: 'Marc', country: 'France'}
];
parameters.string;
// => "post=2&date=10%2F12%2F1997&authors[][name]=Marie&authors[][country]=England&authors[][name]=Marc&authors[][country]=France"

var otherParameters = new Parameters();
otherParameters.string = "post=2&date=10%2F12%2F1997&authors[][name]=Marie&authors[][country]=England&authors[][name]=Marc&authors[][country]=France";
otherParameters;
// => Parameters {
//      post: '2',
//      date: '10/12/1997',
//      authors: [
//        {name: 'Marie', country: 'England'},
//        {name: 'Marc', country: 'France'}
//      ]
//    }

Parameters

Kind: global class

new Parameters(...parameters)

Create a Parameters object.

| Param | Type | Description | | --- | --- | --- | | ...parameters | Object | Same value as set's parameters. |

parameters.keys : Array.<string>

The parameters keys.

Kind: instance property of Parameters
Read only: true

parameters.flattened : Array.<FlatParameter>

A flat array corresponding to the parameters. When set, the given flattened parameters array will be parsed to replace the current parameters.

Kind: instance property of Parameters

parameters.string : string

A string corresponding to the parameters, ready to be used in a url. When set, the given string will be parsed to replace the current parameters.

Kind: instance property of Parameters

parameters.inputs : FragmentDocument | NodeList | Array

A set of inputs corresponding the parameters. When set, the given inputs will be parsed to replace the current parameters.

Kind: instance property of Parameters

parameters.formData : FormData

A FormData corresponding to the parameters.

Kind: instance property of Parameters
Read only: true

parameters.form : HTMLFormElement | Element

A Form corresponding to the parameters. When set, the given form inputs be parsed to replace the current parameters.

Kind: instance property of Parameters

parameters.json : string

A json string corresponding to the parameters. When set, the given json string will be parsed to replace the current parameters.

Kind: instance property of Parameters

parameters.clone : Parameters

A clone of the current parameters.

Kind: instance property of Parameters
Read only: true

parameters.empty : boolean

true if no value different from null can be found in the parameters, false in the other case.

Kind: instance property of Parameters
Read only: true

parameters.any : boolean

Opposite of empty.

Kind: instance property of Parameters
Read only: true

parameters.toString() ⇒ string

Kind: instance method of Parameters
Returns: string - Value of string

parameters.set(...parameters) ⇒ Parameters

Set parameters.

Kind: instance method of Parameters
Returns: Parameters - Itself.

| Param | Type | Description | | --- | --- | --- | | ...parameters | string | Object | The parameters to set. If string given the assumed value will be null. |

parameters.unset(...keys) ⇒ Parameters

Unset parameters.

Kind: instance method of Parameters
Returns: Parameters - Itself.

| Param | Type | Description | | --- | --- | --- | | ...keys | Object | The parameter keys to unset. |

parameters.index(key, [callback]) ⇒ number

Looks for the index of the given key and call callback if it was found.

Kind: instance method of Parameters
Returns: number - The index of the given key if it exists, null in the other case.

| Param | Type | Description | | --- | --- | --- | | key | string | The parameter key whose index your looking for | | [callback] | indexCallback | The function to call if an index has been found for this key. |

parameters.have(key, [callback]) ⇒ boolean

Checks that the given key exists and call a callback if it exists.

Kind: instance method of Parameters
Returns: boolean - true if the key exists, false in the other case.

| Param | Type | Description | | --- | --- | --- | | key | string | The parameter key you want to check the existence. | | [callback] | haveCallback | The function to call if the key exists. |

parameters.each(callback) ⇒ Parameters

Iterates through parameters.

Kind: instance method of Parameters
Returns: Parameters - Itself.

| Param | Type | Description | | --- | --- | --- | | callback | eachCallback | The function to call for each parameter. |

parameters.map(callback) ⇒ Parameters

Iterates through parameters and replaces values.

Kind: instance method of Parameters
Returns: Parameters - Itself.

| Param | Type | Description | | --- | --- | --- | | callback | mapCallback | The function to call for each parameter. |

parameters.reset() ⇒ Parameters

Set all parameter values to null.

Kind: instance method of Parameters
Returns: Parameters - Itself

parameters.clear() ⇒ Parameters

Removes all the parameters.

Kind: instance method of Parameters
Returns: Parameters - Itself

FlatParameter : Object

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | key | string | The flattened key of the parameter. | | value | string | number | boolean | The value of the parameter |

indexCallback : function

Kind: global typedef

| Param | Type | Description | | --- | --- | --- | | index | number | The index of the key. |

haveCallback : function

Kind: global typedef

eachCallback ⇒ boolean

Kind: global typedef
Returns: boolean - If strictly equal to false, will stop iterating.

| Param | Type | Description | | --- | --- | --- | | key | string | The current key. | | value | * | The current value. |

mapCallback ⇒ *

Kind: global typedef
Returns: * - The value that will replace the current value.

| Param | Type | Description | | --- | --- | --- | | key | string | The current key. | | value | * | The current value. |

Classes

Typedefs