@aaronhayes/qstring
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

qstring

npm (scoped) Build Codecov Bundle Size License

The easiest way to build querystrings. A lightweight, easy to use way to build full urls including the querystring. Less than 400B Minified & GZipped!

The popular query-string only handles the part querystring part, so there is another step of building the final url. The API inspired by JedWatson's Classnames Package.

Install

$ npm install --save @aaronhayes/qstring
$ yarn add @aaronhayes/qstring

Usage

import qstring, { ArrayFormat } from '@aaronhayes/qstring';

const qs = qstring('https://myapi.com', {
    foo: 'bar',
    foobar: true,
    foo3: null,
    foo4: undefined
});

console.log(qs);
// https://myapi.com?foo=bar&foobar=true

const qs = qstring(
    'https://myapi.com',
    {
        foo: ['hello', 'world'],
        cat: 'dog'
    }
);

console.log(qs);
// https://myapi.com?foo=hello&foo=world&cat=dog

const qs = qstring(
    'https://myapi.com',
    {
        foo: ['hello', 'world'],
        cat: 'dog'
    },
    ArrayFormat.comma
);

console.log(qs);
// https://myapi.com?foo=hello,world&cat=dog

See Also

Package Sidebar

Install

npm i @aaronhayes/qstring

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

13.4 kB

Total Files

10

Last publish

Collaborators

  • aaronhayes