@@ -7,16 +7,16 @@ import gleam/javascript/array.{type Array}
7
7
///
8
8
/// This library assumes you have some familiarity with JavaScript promises. If
9
9
/// you are not then you may want to take the time to learn about them outside of
10
- /// Gleam.
10
+ /// Gleam.
11
11
///
12
12
/// The Gleam promise type is generic over the type of value it resolves. It is
13
13
/// not generic over the error type as any Gleam panic or JavaScript exception
14
- /// could alter the error value in an way that undermines the type, making it
14
+ /// could alter the error value in an way that undermines the type, making it
15
15
/// unsound and untypable.
16
16
/// If you want to represent success and failure with promises use a Gleam
17
17
/// `Result` inside of a promise.
18
18
///
19
- /// For further information view the MDN documentation:
19
+ /// For further information view the MDN documentation:
20
20
/// <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise>
21
21
///
22
22
pub type Promise ( value)
@@ -123,15 +123,17 @@ pub fn try_await(
123
123
/// Chain an asynchronous operation onto an array of promises, so it runs after the
124
124
/// promises have resolved.
125
125
///
126
- /// This is the equivilent of the `Promise.all` JavaScript static method.
126
+ /// This is the equivilent of the [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
127
+ /// JavaScript static method.
127
128
///
128
129
@ external ( javascript , "../../gleam_javascript_ffi.mjs" , "all_promises" )
129
130
pub fn await_array ( a : Array ( Promise ( a) ) ) -> Promise ( Array ( a) )
130
131
131
132
/// Chain an asynchronous operation onto an list of promises, so it runs after the
132
133
/// promises have resolved.
133
134
///
134
- /// This is the equivilent of the `Promise.all` JavaScript static method.
135
+ /// This is the equivilent of the [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)
136
+ /// JavaScript static method.
135
137
///
136
138
pub fn await_list ( xs : List ( Promise ( a) ) ) -> Promise ( List ( a) ) {
137
139
xs
@@ -142,9 +144,21 @@ pub fn await_list(xs: List(Promise(a))) -> Promise(List(a)) {
142
144
@ external ( javascript , "../../gleam_javascript_ffi.mjs" , "all_promises" )
143
145
fn do_await_list ( a : List ( Promise ( a) ) ) -> Promise ( Array ( a) )
144
146
147
+ /// Wait for the first promise to settle. Any promise settling after the
148
+ /// first one is ignored.
149
+ ///
150
+ /// This is the equivalent of the [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
151
+ /// JavaScript static method.
152
+ ///
145
153
@ external ( javascript , "../../gleam_javascript_ffi.mjs" , "race_promises" )
146
154
pub fn race_list ( a : List ( Promise ( a) ) ) -> Promise ( a)
147
155
156
+ /// Wait for the first promise to settleAny promise settling after the
157
+ /// first one is ignored.
158
+ ///
159
+ /// This is the equivalent of the [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race)
160
+ /// JavaScript static method.
161
+ ///
148
162
@ external ( javascript , "../../gleam_javascript_ffi.mjs" , "race_promises" )
149
163
pub fn race_array ( a : Array ( Promise ( a) ) ) -> Promise ( a)
150
164
0 commit comments