Package Exports
- qss
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (qss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
qss 
A tiny (202b) browser utility for stringifying a query Object.
You should only consider using this within a browser context since Node's built-in querystring.stringify
is much faster and should be used in a Node environment! An ideal use case is serializing a query object before an API request is sent.
This module exposes three module definitions:
- ES Module:
dist/qss.mjs
- CommonJS:
dist/qss.js
- UMD:
dist/qss.min.js
Install
$ npm install --save qss
Usage
import qss from 'qss';
qss({ foo:'hello', bar:[1,2,3], baz:true });
//=> 'foo=hello&bar=1&bar=2&bar=3&baz=true'
qss({ foo:123 }, '?');
//=> '?foo=123'
qss({ bar:'world' }, 'foo=hello&');
//=> 'foo=hello&bar=world'
API
qss(params, prefix)
params
Type: Object
The object that contains all query parameter keys & their values.
prefix
Type: String
Default: ''
An optional prefix. The stringified params
will be appended to this value, so it must end with your desired joiner; eg ?
.
Important: No checks or validations will run on your
prefix
. Similarly, no character is used to "glue" the query string to yourprefix
string.
Benchmarks
qss
--> 1,218,706 ops/sec ±0.24% (94 runs sampled)
native
--> 4,271,253 ops/sec ±0.84% (93 runs sampled)
query-string
--> 267,467 ops/sec ±0.88% (90 runs sampled)
querystringify
--> 1,046,418 ops/sec ±0.23% (94 runs sampled)
License
MIT © Luke Edwards