fernandofleury / query-object

A lightweight lib to work with query strings (< 1kb uglified & gzipped)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

query-object

CircleCI Coverage Status Commitizen friendly semantic-release

A lightweight lib to work with query strings (< 1kb uglified & gzipped)

Please note this small/opinionated does not support Arrays[], for those scenarios there are other libraries who can handle it pretty well!

Install

npm install --save query-object

API

The v3 has a totally new and simpler API. All previous methods from v2 has been deprecated in favor of parse/stringify:

parse(querystring: string)

Returns the current query string as a key/value object.

const queryObject = require('queryObject')

queryObject.parse('?foo=foo&bar=bar&baz')
// returns {foo: 'foo', bar: 'bar', baz: null}

queryObject.parse('?foo=foo');
// returns {foo: 'foo'}

stringify(params: object)

Returns a new string based on the provided object.

const queryObject = require('queryObject')

queryObject.stringify({ foo: 'foo' })
// returns 'foo=foo'

queryObject.stringify({ foo: 'foo', bar: null })
// returns 'foo=foo&bar'

License

MIT License

About

A lightweight lib to work with query strings (< 1kb uglified & gzipped)

License:MIT License


Languages

Language:JavaScript 100.0%