https://github.com/aaronhayes/qstring
The easiest way to build query strings
https://github.com/aaronhayes/qstring
qs query-string query-string-builder querystring typescript
Last synced: 2 months ago
JSON representation
The easiest way to build query strings
- Host: GitHub
- URL: https://github.com/aaronhayes/qstring
- Owner: aaronhayes
- License: mit
- Created: 2019-10-17T12:17:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-14T01:22:10.000Z (over 5 years ago)
- Last Synced: 2025-03-17T19:46:39.422Z (3 months ago)
- Topics: qs, query-string, query-string-builder, querystring, typescript
- Language: TypeScript
- Size: 115 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# qstring
[](https://www.npmjs.com/package/@aaronhayes/qstring)


[](https://bundlephobia.com/result?p=@aaronhayes/[email protected])
The easiest way to build querystrings. A lightweight, easy to use way to build full urls including the querystring. Less than [400B Minified & GZipped](https://bundlephobia.com/result?p=@aaronhayes/[email protected])!
The popular [query-string](https://github.com/sindresorhus/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](https://github.com/JedWatson/classnames) Package.
## Install
```
$ npm install --save @aaronhayes/qstring
``````
$ yarn add @aaronhayes/qstring
```## Usage
```TypeScript
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=trueconst qs = qstring(
'https://myapi.com',
{
foo: ['hello', 'world'],
cat: 'dog'
}
);console.log(qs);
// https://myapi.com?foo=hello&foo=world&cat=dogconst 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
- [query-string](https://github.com/sindresorhus/query-string)
- [Classnames](https://github.com/JedWatson/classnames)
- [Typescript Starter](https://github.com/bitjson/typescript-starter)