@knownasrazi/querystring
v1.0.0
Published
Parse and stringify query strings with nested object and array support.
Maintainers
Readme
querystring
Parse and stringify query strings, nested + arrays.
Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser
Install
bun add @knownasrazi/querystring
npm install @knownasrazi/querystringUsage
import { parse, stringify } from "@knownasrazi/querystring";
parse("a=1&b=2"); // { a: "1", b: "2" }
parse("user[name]=razi&user[age]=30"); // { user: { name: "razi", age: "30" } }
parse("a[]=1&a[]=2"); // { a: ["1", "2"] }
stringify({ tags: ["a", "b"] }); // "tags=a&tags=b"
stringify({ nested: { x: "y" } }); // "nested[x]=y"API
| Export | Description |
| --- | --- |
| parse(input, opts?) | string -> Record<string, QueryValue> |
| stringify(data, opts?) | Record<string, QueryValue> -> string |
Options: nested, encode/decode flags.
Development
git clone https://github.com/knownasrazi/querystring.git
cd querystring
bun install
bun test
bun run build
bun run lintLicense
querystring - urls that nest.
