mini-querystring
Version:
Lightweight isomorphic querystring parser.
27 lines (26 loc) • 756 B
TypeScript
/**
* @description
* Converts an object to a query string and optionally flattens it.
*
* @example
* stringify({ a: 1 }) === 'a=1'
*
* stringify({ a: { b: 1 } }, true) === 'a[b]=1'
*
* @param obj The object to stringify.
* @param deep If true the object will be flattened using query string syntax.
*/
export declare function stringify(obj: any, deep?: boolean): string;
/**
* @description
* Parses a query string and optionally unflattens it.
*
* @example
* parse('a=1&b=2&') === "{ a: '1', b: '2' }"
*
* parse('a=1&b[c]=2', true) === "{ a: '1', b: { c: '1' } }"
*
* @param str The string to parse.
* @param deep If true, nested querystring paths will be resolved.
*/
export declare function parse(str: string, deep?: boolean): any;