liquidsoap-prettier 1.4.6 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ocamlformat +10 -0
- package/dist/liquidsoap.cjs +102614 -97962
- package/dist/web.mjs +1 -1
- package/package.json +1 -1
- package/src/dune +1 -1
- package/src/liquidsoap_js.ml +9 -5
- package/src/regexp_js.ml +0 -57
- package/src/regexp_js.mli +0 -4
package/package.json
CHANGED
package/src/dune
CHANGED
package/src/liquidsoap_js.ml
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
open Js_of_ocaml
|
|
2
|
-
open Liquidsoap_lang
|
|
3
|
-
|
|
4
|
-
let () =
|
|
5
|
-
Hooks.regexp := Regexp_js.make
|
|
6
2
|
|
|
7
3
|
let parse content =
|
|
8
4
|
let content = Js.to_string content in
|
|
9
|
-
let json =
|
|
5
|
+
let json =
|
|
6
|
+
let buf = Buffer.create 0 in
|
|
7
|
+
let formatter = Format.formatter_of_buffer buf in
|
|
8
|
+
try Liquidsoap_tooling.Parsed_json.parse_string ~formatter content
|
|
9
|
+
with _ ->
|
|
10
|
+
Js_error.raise_
|
|
11
|
+
(Js_error.of_error
|
|
12
|
+
(new%js Js.error_constr (Js.string (Buffer.contents buf))))
|
|
13
|
+
in
|
|
10
14
|
Js._JSON##parse
|
|
11
15
|
(Js.string (Liquidsoap_lang.Json.to_string ~compact:true json))
|
|
12
16
|
|
package/src/regexp_js.ml
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
open Js_of_ocaml
|
|
2
|
-
|
|
3
|
-
type sub = Liquidsoap_lang.Regexp.sub = {
|
|
4
|
-
matches : string option list;
|
|
5
|
-
groups : (string * string) list;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
class type match_result =
|
|
9
|
-
object
|
|
10
|
-
inherit Js.match_result
|
|
11
|
-
method groups : Js.Unsafe.any Js.optdef Js.readonly_prop
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let string_of_flag = function `i -> "i" | `g -> "g" | `s -> "s" | `m -> "m"
|
|
15
|
-
|
|
16
|
-
let flags_of_flags flags =
|
|
17
|
-
Js.string (String.concat "" (List.map string_of_flag flags))
|
|
18
|
-
|
|
19
|
-
let make ?(flags = []) s =
|
|
20
|
-
let rex = new%js Js.regExp_withFlags (Js.string s) (flags_of_flags flags) in
|
|
21
|
-
object
|
|
22
|
-
method split s =
|
|
23
|
-
let split = (Js.string s)##split_regExp rex in
|
|
24
|
-
let split = Js.str_array split in
|
|
25
|
-
Array.to_list (Array.map Js.to_string (Js.to_array split))
|
|
26
|
-
|
|
27
|
-
method exec s =
|
|
28
|
-
let s = Js.string s in
|
|
29
|
-
let ret =
|
|
30
|
-
Js.Opt.case (rex##exec s) (fun () -> raise Not_found) (fun x -> x)
|
|
31
|
-
in
|
|
32
|
-
let sub : match_result Js.t = Js.Unsafe.coerce (Js.match_result ret) in
|
|
33
|
-
let matches =
|
|
34
|
-
List.init sub##.length (fun pos ->
|
|
35
|
-
Option.map Js.to_string (Js.Optdef.to_option (Js.array_get sub pos)))
|
|
36
|
-
in
|
|
37
|
-
let groups =
|
|
38
|
-
Js.Optdef.case sub##.groups
|
|
39
|
-
(fun () -> [])
|
|
40
|
-
(fun groups ->
|
|
41
|
-
let names = Js.to_array (Js.object_keys groups) in
|
|
42
|
-
Array.fold_left
|
|
43
|
-
(fun cur key ->
|
|
44
|
-
Js.Optdef.case (Js.Unsafe.get groups key)
|
|
45
|
-
(fun () -> cur)
|
|
46
|
-
(fun value -> (Js.to_string key, Js.to_string value) :: cur))
|
|
47
|
-
[] names)
|
|
48
|
-
in
|
|
49
|
-
{ matches; groups }
|
|
50
|
-
|
|
51
|
-
method test s = Js.to_bool (rex##test (Js.string s))
|
|
52
|
-
|
|
53
|
-
method substitute ~subst s =
|
|
54
|
-
let subst a = Js.string (subst (Js.to_string a)) in
|
|
55
|
-
let subst = Js.wrap_callback subst in
|
|
56
|
-
Js.to_string ((Js.Unsafe.coerce (Js.string s))##replace rex subst)
|
|
57
|
-
end
|
package/src/regexp_js.mli
DELETED