Skip to content

Instantly share code, notes, and snippets.

@liubko
Created April 3, 2018 17:24
Show Gist options
  • Save liubko/5ed1192333f8ef1166027702576070d6 to your computer and use it in GitHub Desktop.
Save liubko/5ed1192333f8ef1166027702576070d6 to your computer and use it in GitHub Desktop.
[@bs.module]
external encode' :
(
Js.t({..}),
Js.nullable(string),
Js.nullable(string),
Js.nullable(string)
) =>
string =
"querystring/encode";
let encode = (~sep=?, ~eq=?, ~name=?, obj) =>
Js.Nullable.(
encode'(obj, fromOption(sep), fromOption(eq), fromOption(name))
);
let stringify = encode;
type options = {. "maxKeys": int};
[@bs.module]
external decode' :
(
string,
Js.nullable(string),
Js.nullable(string),
Js.nullable(options)
) =>
Js.t({..}) =
"querystring/decode";
let decode = (~sep=?, ~eq=?, ~options=?, qsStr) =>
Js.Nullable.(
decode'(qsStr, fromOption(sep), fromOption(eq), fromOption(options))
);
let parse = decode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment