super-qs
Create and parse URL-safe query strings from arbitrary values.
Install with
npm i super-qs
yarn add super-qs
pnpm i super-qs
bun add super-qs
Use cases
- Sending data to a browser extension popup.
- Creating shareable links containing application state.
Usage
import { stringify, parse } from "super-qs";
const data = {
bool: true,
undef: undefined,
nullVal: null,
date: new Date(),
hugeNum: 0xffffffffffffffffffffn,
bin: new Uint8Array([42, 24]),
};
const stringifiedData = stringify(data);
const url = new URL(`https://example.com?data=${stringifiedData}`);
const params = new URLSearchParams(url.search);
const stringifiedDataParam = params.get("data");
const parsedData = parse(stringifiedDataParam);
expect(parsedData).toEqual(data);
Development
Get started with
bun install
Run tests with
bun run test
Build the package with
bun run build