diff options
author | Joris | 2020-07-26 18:16:59 +0200 |
---|---|---|
committer | Joris | 2020-07-26 18:16:59 +0200 |
commit | 4ee0dfae75fda3a8b6347d55c728b50ce5c210d9 (patch) | |
tree | 5f73adaf57354e0070acaa9a6b60dc49c0c48526 /src/Lib/String.ml | |
parent | 447f43995ae8d83c82d98d9d8968e90d6c4518e7 (diff) |
Allow to customize icons
Diffstat (limited to 'src/Lib/String.ml')
-rw-r--r-- | src/Lib/String.ml | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Lib/String.ml b/src/Lib/String.ml new file mode 100644 index 0000000..be16d0e --- /dev/null +++ b/src/Lib/String.ml @@ -0,0 +1,35 @@ +let format_float precision f = + let str = Js.Float.toString f in + match Js.String.split "." str with + | [| a ; b |] -> a ^ "." ^ (Js.String.substring ~from:0 ~to_:precision b) + | _ -> str + +external btoa : string -> string = "btoa" + [@@bs.val] [@@bs.scope "window"] + +external atob : string -> string = "atob" + [@@bs.val] [@@bs.scope "window"] + +external unescape : string -> string = "unescape" + [@@bs.val] + +external escape : string -> string = "escape" + [@@bs.val] + +external encodeURIComponent : string -> string = "encodeURIComponent" + [@@bs.val] + +external decodeURIComponent : string -> string = "decodeURIComponent" + [@@bs.val] + +let encode str = + str + |> encodeURIComponent + |> unescape + |> btoa + +let decode str = + str + |> atob + |> escape + |> decodeURIComponent |