@@ -14,17 +14,17 @@ let foo = async (. x, y) => x + y
14
14
let bar =
15
15
async
16
16
(. ff ) => {
17
- let a = @ res. await ff (. 3 , 4 )
18
- let b = @ res. await foo (. 5 , 6 )
17
+ let a = await ff (. 3 , 4 )
18
+ let b = await foo (. 5 , 6 )
19
19
a + b
20
20
}
21
21
22
- let baz = async (. ()) => @ res. await bar (. foo )
22
+ let baz = async (. ()) => await bar (. foo )
23
23
24
24
let testBaz : testable =
25
25
async
26
26
(. ()) => {
27
- let n = @ res. await baz (.)
27
+ let n = await baz (.)
28
28
Js .log2 ("baz returned" , n )
29
29
}
30
30
@@ -38,14 +38,14 @@ exception E(int)
38
38
39
39
let e1 : testable = async (. ()) => raise (E (1000 ))
40
40
let e2 : testable = async (. ()) => Js .Exn .raiseError ("Some JS error" )
41
- let e3 : testable = async (. ()) => @ res. await e1 (.)
42
- let e4 : testable = async (. ()) => @ res. await e2 (.)
41
+ let e3 : testable = async (. ()) => await e1 (.)
42
+ let e4 : testable = async (. ()) => await e2 (.)
43
43
let e5 : testable = %raw (` function () { return Promise .reject (new Error (' fail' )) }` )
44
44
45
45
let testTryCatch =
46
46
async
47
47
(. fn ) =>
48
- try {@ res. await fn (.)} catch {
48
+ try {await fn (.)} catch {
49
49
| E (n ) => Js .log2 ("testTryCatch: E" , n )
50
50
| JsError (_ ) => Js .log ("testTryCatch: JsError" )
51
51
}
@@ -87,7 +87,7 @@ let testFetch =
87
87
async
88
88
(. url ) => {
89
89
open Fetch
90
- switch {@ res. await fetch (url )} {
90
+ switch {await fetch (url )} {
91
91
| response =>
92
92
let status = response -> status
93
93
Js .log2 ("Fetch returned status:" , status )
@@ -104,11 +104,11 @@ testFetch->addTest1("https://www.google.comsdkjdkghdsg")
104
104
let withCallback =
105
105
async
106
106
(. ()) => {
107
- async (. x ) => @ res. await (x -> Js .Promise .resolve ) + 1
107
+ async (. x ) => await (x -> Js .Promise .resolve ) + 1
108
108
}
109
109
110
110
let testWithCallback =
111
- async (. ()) => Js .log2 ("callback returned" , @ res. await (@ res. await withCallback (.))(. 3 ))
111
+ async (. ()) => Js .log2 ("callback returned" , await (await withCallback (.))(. 3 ))
112
112
113
113
testWithCallback -> addTest
114
114
@@ -124,10 +124,10 @@ module AsyncList = {
124
124
(. l , acc ) =>
125
125
switch l {
126
126
| list {} => acc
127
- | list {p , ... rest } => @ res. await loop (. rest , list {@ res. await p , ... acc })
127
+ | list {p , ... rest } => await loop (. rest , list {await p , ... acc })
128
128
}
129
129
130
- @ res. await
130
+ await
131
131
loop (. l -> Belt .List .mapReverse (x => f (. x )), list {})
132
132
}
133
133
}
@@ -138,7 +138,7 @@ let fetchAndCount = {
138
138
let ff =
139
139
async
140
140
(. url ) => {
141
- let response = @ res. await Fetch .fetch (url )
141
+ let response = await Fetch .fetch (url )
142
142
counter := counter .contents + 1
143
143
(counter .contents , response -> Fetch .status )
144
144
}
@@ -150,7 +150,7 @@ let testFetchMany =
150
150
async
151
151
(. ()) => {
152
152
let fetchedItems =
153
- @ res. await
153
+ await
154
154
AsyncList .map (.
155
155
list {
156
156
"https://www.google.com" ,
@@ -172,7 +172,7 @@ module FetchResult = {
172
172
let fetch =
173
173
async
174
174
(. url ) => {
175
- switch {@ res. await Fetch .fetch (url )} {
175
+ switch {await Fetch .fetch (url )} {
176
176
| response => Ok (response )
177
177
| exception JsError (e ) => Error (e )
178
178
}
@@ -184,14 +184,14 @@ let nextFetch = (. _response) => Some("https://github.com/")
184
184
let testFetchWithResult =
185
185
async
186
186
(. ()) => {
187
- switch @ res. await
187
+ switch await
188
188
FetchResult .fetch (. "https://www.google.com" ) {
189
189
| Ok (response1 ) =>
190
190
Js .log2 ("FetchResult response1" , response1 -> Fetch .status )
191
191
switch nextFetch (. response1 ) {
192
192
| None => ()
193
193
| Some (url ) =>
194
- switch @ res. await
194
+ switch await
195
195
FetchResult .fetch (. url ) {
196
196
| Ok (response2 ) => Js .log2 ("FetchResult response2" , response2 -> Fetch .status )
197
197
| Error (_ ) => ()
@@ -219,10 +219,10 @@ let rec runAllTests =
219
219
async
220
220
(. n ) => {
221
221
if n >= 0 && n < Array .length (tests ) {
222
- @ res. await
222
+ await
223
223
(@doesNotRaise tests [n ])(.)
224
224
225
- @ res. await
225
+ await
226
226
runAllTests (. n + 1 )
227
227
}
228
228
}
@@ -233,13 +233,13 @@ runAllTests(. 0)->ignore
233
233
//
234
234
// Curried functions
235
235
236
- let bb = async x => @ res. await x
236
+ let bb = async x => await x
237
237
238
- let cc = async (x , ~y = x , z ) => (@ res. await x ) + (@ res. await y ) + (@ res. await z )
238
+ let cc = async (x , ~y = x , z ) => (await x ) + (await y ) + (await z )
239
239
240
- let dd = async x => {y => (@ res. await x ) + (@ res. await y )}
240
+ let dd = async x => {y => (await x ) + (await y )}
241
241
242
- let ee = async (. x ) => {y => (@ res. await x ) + (@ res. await y )}
242
+ let ee = async (. x ) => {y => (await x ) + (await y )}
243
243
244
244
//
245
245
//
@@ -248,8 +248,8 @@ let ee = async (. x) => {y => (@res.await x) + (@res.await y)}
248
248
// let aa =
249
249
// async
250
250
// (. x) => {
251
- // let cb = (. _) => @res. await x // Error: Await on expression not in an async context
251
+ // let cb = (. _) => await x // Error: Await on expression not in an async context
252
252
// cb
253
253
// }
254
254
255
- // let _ = async (_, . x) => @res. await x // Error: Await on expression not in an async context
255
+ // let _ = async (_, . x) => await x // Error: Await on expression not in an async context
0 commit comments