Socket
Book a DemoInstallSign in
Socket

queri

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queri

Parse, stringify and manage your URI queries.

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
19
11.76%
Maintainers
1
Weekly downloads
 
Created
Source

queri.js

Parse, stringify and manage your URI queries.
Library does not operates with window.location or pushState, if you need to - you got to do it yourself.

queri.js supports HTTP Queries of any nesting, according it's RFC

Usage

  • Include Queri.js
    You can include module via require('queri'); in NodeJS
    Or you can link Queri.js directly to your page via <script src="queri.js"></script>
    IMPORTANT! Queri class will be available as a global variable
  • Enjoy
    Use Queri.js whatever you like to
let q = new Queri('foo=bar&bar[]=1&bar[]=2&bar[]=3&baz=bat');
q.get('foo');   // ->> bar
q.get('bar');   // ->> [1, 2, 3]

q.set('bar', null)
 .stringify();  // ->> 'foo=bar&baz=bat'
 
q.query = 'a=b&c=d';
q.get('foo', false);    // ->> false
q.get();                // ->> {a: "b", c: "d"}
q.query;                // ->> {a: "b", c: "d"}

q.set('c', null)
 .stringify();  // ->> a=b
 
q.remove()
 .stringify();  // ->> ""
 
new Queri({a: "b", c: "d"}) === new Queri('a=b&c=d');

Doc

.query

property, object representing current query

constructor ( input = {} )

method, returns new Queri object

get ( key = null, defaultValue = null )

method, returns .query[key] or default value if first one not presented, or whole .query if key is null

set ( key, val )

method, returns self

remove ( key = null )

method, returns self

stringify ( )

method, returns stringified version of .query

Keywords

uri

FAQs

Package last updated on 31 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts