Skip to content

Commit 31073bd

Browse files
committed
remove Js.Promise2
1 parent ea22e4a commit 31073bd

15 files changed

+624
-700
lines changed

Diff for: jscomp/others/js_promise.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
]}
3030
*)
3131

32-
type + 'a t = 'a Js_promise2.t
33-
type error = Js_promise2.error
32+
type + 'a t
33+
type error
3434

3535

3636
external make : (resolve:('a -> unit [@bs]) ->

Diff for: jscomp/others/js_promise2.ml

-69
This file was deleted.

Diff for: jscomp/others/release.ninja

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ build others/js_null_undefined.cmi : cc others/js_null_undefined.mli | runtime
3636
build others/js_obj.cmi others/js_obj.cmj : cc others/js_obj.ml | runtime
3737
build others/js_option.cmj : cc others/js_option.ml | others/js_exn.cmj others/js_option.cmi runtime
3838
build others/js_option.cmi : cc others/js_option.mli | runtime
39-
build others/js_promise.cmi others/js_promise.cmj : cc others/js_promise.ml | others/js_promise2.cmj runtime
40-
build others/js_promise2.cmi others/js_promise2.cmj : cc others/js_promise2.ml | runtime
39+
build others/js_promise.cmi others/js_promise.cmj : cc others/js_promise.ml | runtime
4140
build others/js_re.cmi : cc others/js_re.mli | runtime
4241
build others/js_result.cmj : cc others/js_result.ml | others/js_result.cmi runtime
4342
build others/js_result.cmi : cc others/js_result.mli | runtime
@@ -51,7 +50,7 @@ build others/js_undefined.cmj : cc others/js_undefined.ml | others/js_exn.cmj ot
5150
build others/js_undefined.cmi : cc others/js_undefined.mli | runtime
5251
build others/js_vector.cmj : cc others/js_vector.ml | others/js_array2.cmj others/js_vector.cmi runtime
5352
build others/js_vector.cmi : cc others/js_vector.mli | runtime
54-
build js_pkg : phony others/js_array.cmi others/js_array.cmj others/js_array2.cmi others/js_array2.cmj others/js_cast.cmi others/js_cast.cmj others/js_console.cmi others/js_console.cmj others/js_date.cmi others/js_date.cmj others/js_dict.cmi others/js_dict.cmj others/js_exn.cmi others/js_exn.cmj others/js_float.cmi others/js_float.cmj others/js_global.cmi others/js_global.cmj others/js_int.cmi others/js_int.cmj others/js_json.cmi others/js_json.cmj others/js_list.cmi others/js_list.cmj others/js_mapperRt.cmi others/js_mapperRt.cmj others/js_math.cmi others/js_math.cmj others/js_null.cmi others/js_null.cmj others/js_null_undefined.cmi others/js_null_undefined.cmj others/js_obj.cmi others/js_obj.cmj others/js_option.cmi others/js_option.cmj others/js_promise.cmi others/js_promise.cmj others/js_promise2.cmi others/js_promise2.cmj others/js_re.cmi others/js_result.cmi others/js_result.cmj others/js_string.cmi others/js_string.cmj others/js_string2.cmi others/js_string2.cmj others/js_typed_array.cmi others/js_typed_array.cmj others/js_typed_array2.cmi others/js_typed_array2.cmj others/js_types.cmi others/js_types.cmj others/js_undefined.cmi others/js_undefined.cmj others/js_vector.cmi others/js_vector.cmj
53+
build js_pkg : phony others/js_array.cmi others/js_array.cmj others/js_array2.cmi others/js_array2.cmj others/js_cast.cmi others/js_cast.cmj others/js_console.cmi others/js_console.cmj others/js_date.cmi others/js_date.cmj others/js_dict.cmi others/js_dict.cmj others/js_exn.cmi others/js_exn.cmj others/js_float.cmi others/js_float.cmj others/js_global.cmi others/js_global.cmj others/js_int.cmi others/js_int.cmj others/js_json.cmi others/js_json.cmj others/js_list.cmi others/js_list.cmj others/js_mapperRt.cmi others/js_mapperRt.cmj others/js_math.cmi others/js_math.cmj others/js_null.cmi others/js_null.cmj others/js_null_undefined.cmi others/js_null_undefined.cmj others/js_obj.cmi others/js_obj.cmj others/js_option.cmi others/js_option.cmj others/js_promise.cmi others/js_promise.cmj others/js_re.cmi others/js_result.cmi others/js_result.cmj others/js_string.cmi others/js_string.cmj others/js_string2.cmi others/js_string2.cmj others/js_typed_array.cmi others/js_typed_array.cmj others/js_typed_array2.cmi others/js_typed_array2.cmj others/js_types.cmi others/js_types.cmj others/js_undefined.cmi others/js_undefined.cmj others/js_vector.cmi others/js_vector.cmj
5554
build others/belt_Array.cmj : cc others/belt_Array.ml | others/belt.cmi others/belt_Array.cmi others/js_math.cmj js_pkg runtime
5655
build others/belt_Array.cmi : cc others/belt_Array.mli | runtime
5756
build others/belt_Debug.cmi others/belt_Debug.cmj : cc others/belt_Debug.ml | runtime

Diff for: jscomp/runtime/js.ml

-3
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,6 @@ module Re2 = Js_re2
238238
module Promise = Js_promise
239239
(** Provide bindings to JS promise *)
240240

241-
module Promise2 = Js_promise2
242-
(** Provide bindings to JS promise *)
243-
244241
module Date = Js_date
245242
(** Provide bindings for JS Date *)
246243

Diff for: jscomp/test/js_promise_basic_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Mt.from_pair_suites("Js_promise_basic_test", suites[0]);
288288
var twop = Promise.resolve(2);
289289

290290
function then_(prim, prim$1) {
291-
return prim.then(Curry.__1(prim$1));
291+
return prim$1.then(Curry.__1(prim));
292292
}
293293

294294
function re(prim) {

Diff for: jscomp/test/js_promise_basic_test.ml

+44-44
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let eq loc x y =
77

88

99

10-
open Js_promise2
10+
open Js_promise
1111

1212
let assert_bool b =
1313
if b then ()
@@ -20,12 +20,12 @@ let fail _ =
2020

2121
let thenTest () =
2222
let p = resolve 4 in
23-
p |. then_ (fun x -> resolve @@ assert_bool (x = 4))
23+
p |> then_ (fun x -> resolve @@ assert_bool (x = 4))
2424

2525
let andThenTest () =
2626
let p = resolve 6 in
27-
p |. then_ (fun _ -> resolve (12))
28-
|. then_ (fun y -> resolve @@ assert_bool (y = 12))
27+
p |> then_ (fun _ -> resolve (12))
28+
|> then_ (fun y -> resolve @@ assert_bool (y = 12))
2929

3030
let h = resolve ()
3131

@@ -38,66 +38,66 @@ let assertIsNotFound (x : Js_promise.error) =
3838
(** would be nice to have [%bs.open? Stack_overflow]*)
3939
let catchTest () =
4040
let p = reject Not_found in
41-
p |. then_ fail
42-
|. catch (fun error ->
41+
p |> then_ fail
42+
|> catch (fun error ->
4343
assertIsNotFound error
4444
)
4545

4646
let orResolvedTest () =
4747
let p = resolve 42 in
48-
p |. catch (fun _ -> resolve 22)
49-
|. then_ (fun value -> resolve @@ assert_bool (value = 42))
50-
|. catch fail
48+
p |> catch (fun _ -> resolve 22)
49+
|> then_ (fun value -> resolve @@ assert_bool (value = 42))
50+
|> catch fail
5151

5252
let orRejectedTest () =
5353
let p = reject Not_found in
54-
p |. catch (fun _ -> resolve 22)
55-
|. then_ (fun value -> resolve @@ assert_bool (value = 22))
56-
|. catch fail
54+
p |> catch (fun _ -> resolve 22)
55+
|> then_ (fun value -> resolve @@ assert_bool (value = 22))
56+
|> catch fail
5757

5858
let orElseResolvedTest () =
5959
let p = resolve 42 in
60-
p |. catch (fun _ -> resolve 22)
61-
|. then_ (fun value -> resolve @@ assert_bool (value = 42))
62-
|. catch fail
60+
p |> catch (fun _ -> resolve 22)
61+
|> then_ (fun value -> resolve @@ assert_bool (value = 42))
62+
|> catch fail
6363

6464
let orElseRejectedResolveTest () =
6565
let p = reject Not_found in
66-
p |. catch (fun _ -> resolve 22)
67-
|. then_ (fun value -> resolve @@ assert_bool (value = 22))
68-
|. catch fail
66+
p |> catch (fun _ -> resolve 22)
67+
|> then_ (fun value -> resolve @@ assert_bool (value = 22))
68+
|> catch fail
6969

7070
let orElseRejectedRejectTest () =
7171
let p = reject Not_found in
72-
p |. catch (fun _ -> reject Stack_overflow)
73-
|. then_ fail
74-
|. catch (fun error ->
72+
p |> catch (fun _ -> reject Stack_overflow)
73+
|> then_ fail
74+
|> catch (fun error ->
7575
match (function [@bs.open] Stack_overflow -> 0) error with
7676
| Some _ -> h
7777
| None -> assert false
7878
(* resolve @@ assert_bool (Obj.magic error == Stack_overflow) *))
7979

8080
let resolveTest () =
8181
let p1 = resolve 10 in
82-
p1 |. then_ (fun x -> resolve @@ assert_bool (x = 10))
82+
p1 |> then_ (fun x -> resolve @@ assert_bool (x = 10))
8383

8484
let rejectTest () =
8585
let p = reject Not_found in
86-
p |. catch
86+
p |> catch
8787
(fun error ->
8888
assertIsNotFound error
8989
(* resolve @@ assert_bool (Obj.magic error == Not_found) *)
9090
)
9191

9292
let thenCatchChainResolvedTest () =
9393
let p = resolve 20 in
94-
p |. then_ (fun value -> resolve @@ assert_bool (value = 20) )
95-
|. catch fail
94+
p |> then_ (fun value -> resolve @@ assert_bool (value = 20) )
95+
|> catch fail
9696

9797
let thenCatchChainRejectedTest () =
9898
let p = reject Not_found in
99-
p |. then_ fail
100-
|. catch (fun error ->
99+
p |> then_ fail
100+
|> catch (fun error ->
101101
assertIsNotFound error
102102
(* resolve @@ assert_bool (Obj.magic error == Not_found) *))
103103

@@ -108,7 +108,7 @@ let allResolvedTest () =
108108
let p3 = resolve 3 in
109109
let promises = [| p1; p2; p3 |] in
110110
all promises
111-
|. then_
111+
|> then_
112112
(fun resolved ->
113113
assert_bool (resolved.(0) = 1) ;
114114
assert_bool (resolved.(1) = 2) ;
@@ -123,26 +123,26 @@ let allRejectTest () =
123123
let p3 = reject Not_found in
124124
let promises = [| p1; p2; p3 |] in
125125
all promises
126-
|. then_ fail
127-
|. catch (fun error -> assert_bool (Obj.magic error == Not_found) ; h)
126+
|> then_ fail
127+
|> catch (fun error -> assert_bool (Obj.magic error == Not_found) ; h)
128128

129129
let raceTest () =
130130
let p1 = resolve "first" in
131131
let p2 = resolve "second" in
132132
let p3 = resolve "third" in
133133
let promises = [| p1; p2; p3 |] in
134134
race promises
135-
|. then_ (fun resolved -> h)
136-
|. catch fail
135+
|> then_ (fun resolved -> h)
136+
|> catch fail
137137

138138
let createPromiseRejectTest () =
139139
make (fun ~resolve ~reject -> reject Not_found [@bs])
140-
|. catch (fun error -> assert_bool (Obj.magic error == Not_found); h)
140+
|> catch (fun error -> assert_bool (Obj.magic error == Not_found); h)
141141

142142
let createPromiseFulfillTest () =
143143
make (fun ~resolve ~reject:_ -> resolve "success" [@bs])
144-
|. then_ (fun resolved -> assert_bool (Obj.magic resolved = "success"); h)
145-
|. catch fail
144+
|> then_ (fun resolved -> assert_bool (Obj.magic resolved = "success"); h)
145+
|> catch fail
146146

147147
let () =
148148
ignore @@ thenTest ();
@@ -164,30 +164,30 @@ let () =
164164
(** TODO: async tests?
165165
*)
166166
let () =
167-
(Js.Promise2.all2 (Js.Promise2.resolve 2, Js.Promise2.resolve 3))
168-
|. Js.Promise2.then_ (fun (a,b) ->
167+
(Js.Promise.all2 (Js.Promise.resolve 2, Js.Promise.resolve 3))
168+
|> Js.Promise.then_ (fun (a,b) ->
169169
eq __LOC__ (a,b) (2,3);
170170

171-
Js.Promise2.resolve ()
171+
Js.Promise.resolve ()
172172
)
173-
|. ignore
173+
|> ignore
174174

175175

176176
;; Js.log (List.length !suites)
177177

178178
;; Js.log "hey"
179179
;; Mt.from_pair_suites __MODULE__ !suites
180180

181-
let twop = Js.Promise2.resolve 2
182-
let then_ = Js.Promise2.then_
183-
let re = Js.Promise2.resolve
181+
let twop = Js.Promise.resolve 2
182+
let then_ = Js.Promise.then_
183+
let re = Js.Promise.resolve
184184

185185
;; Mt.from_promise_suites __MODULE__
186186
[
187187
__LOC__,
188188
twop
189-
|. then_ (fun x -> re @@ Mt.Eq(x,2));
189+
|> then_ (fun x -> re @@ Mt.Eq(x,2));
190190
__LOC__,
191191
twop
192-
|. then_ (fun x -> re @@ Mt.Neq(x,3))
192+
|> then_ (fun x -> re @@ Mt.Neq(x,3))
193193
]

Diff for: jscomp/test/mt.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ external describe : string -> (unit -> unit[@bs]) -> unit = "describe"
77
external it : string -> (unit -> unit[@bs.uncurry]) -> unit = "it"
88
[@@bs.val]
99

10-
external it_promise : string -> (unit -> _ Js.Promise2.t [@bs.uncurry]) -> unit = "it"
10+
external it_promise : string -> (unit -> _ Js.Promise.t [@bs.uncurry]) -> unit = "it"
1111
[@@bs.val]
1212

1313
external eq : 'a -> 'a -> unit = "deepEqual"
@@ -84,7 +84,7 @@ type eq =
8484
(* TODO: | Exception : exn -> (unit -> unit) -> _ eq *)
8585

8686
type pair_suites = (string * (unit -> eq)) list
87-
type promise_suites = (string * eq Js.Promise2.t) list
87+
type promise_suites = (string * eq Js.Promise.t) list
8888
let close_enough ?(threshold=0.0000001 (* epsilon_float *)) a b =
8989
abs_float (a -. b) < threshold
9090

@@ -134,16 +134,16 @@ let from_pair_suites name (suites : pair_suites) =
134134
)
135135
else node_from_pair_suites name suites
136136
| _ -> ()
137-
let val_unit = Js.Promise2.resolve ()
138-
let from_promise_suites name (suites : (string * _ Js.Promise2.t ) list) =
137+
let val_unit = Js.Promise.resolve ()
138+
let from_promise_suites name (suites : (string * _ Js.Promise.t ) list) =
139139
match Array.to_list Node.Process.process##argv with
140140
| cmd :: _ ->
141141
if is_mocha () then
142142
describe name (fun [@bs] () ->
143143
suites |>
144144
List.iter (fun (name, code) ->
145145
it_promise name (fun _ ->
146-
code |. Js.Promise2.then_ (fun x -> handleCode x; val_unit)
146+
code |> Js.Promise.then_ (fun x -> handleCode x; val_unit)
147147

148148
)
149149
)

Diff for: jscomp/test/mt.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type pair_suites = (string * (unit -> eq)) list
1414
val from_suites : string -> (string * (unit -> unit)) list -> unit
1515
val from_pair_suites : string -> pair_suites -> unit
1616

17-
type promise_suites = (string * eq Js.Promise2.t) list
17+
type promise_suites = (string * eq Js.Promise.t) list
1818

1919
val from_promise_suites :
2020
string ->

0 commit comments

Comments
 (0)