query

Parses a query string into an object.

Type signature

(xs?: string) => {
    [index: string]: string | boolean;
}

Examples

parse("test&count=5");
// ⇒ { test: true, count: "5" }
Try in REPL

Questions

  • How to parse a query string?

TypeScript sourceJavaScript source

Parses the given query string into an object using URLSearchParams.

Type signature

(source: string) => Result

Examples

read("test&count=5");
// ⇒ { test: "", count: "5" }
Try in REPL

Questions

  • How to parse a query string using URLSearchParams?

TypeScript sourceJavaScript source

Serializes the given object into a query string.

Type signature

<T>(xs?: GenericObject<T>) => string

Examples

serialize({
  test: true,
  value: "a string with spaces",
  missing: false,
});
// ⇒ "test&value=a%20string%20with%20spaces"
Try in REPL

Questions

  • How to serialize an object to a query string?

TypeScript sourceJavaScript source