You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`withResolvers()` returns a object containing a new promise with functions to resolve or reject it. See [`Promise.withResolvers`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers) on MDN.
86
+
87
+
## Examples
88
+
89
+
```rescript
90
+
open Promise
91
+
92
+
let {promise, resolve, _} = Promise.withResolvers()
`race(arr)` combining `array` of promises. See [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) on MDN.
240
+
`race(arr)` runs all promises concurrently and returns promise settles with the eventual state of the first promise that settles. See [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) on MDN.
`all(promises)` runs all promises in parallel and returns a new promise resolving
237
-
all gathered results in a unified array. See [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) on MDN.
267
+
`any(arr)` runs all promises concurrently and returns promise fulfills when any of the input's promises fulfills, with this first fulfillment value. See [`Promise.any`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any) on MDN.
268
+
269
+
## Examples
270
+
271
+
```rescript
272
+
open Promise
273
+
let racer = (ms, name) => {
274
+
Promise.make((resolve, _) => {
275
+
setTimeout(() => {
276
+
resolve(name)
277
+
}, ms)->ignore
278
+
})
279
+
}
280
+
281
+
let promises = [racer(1000, "Turtle"), racer(500, "Hare"), racer(100, "Eagle")]
282
+
283
+
any(promises)->then(winner => {
284
+
Console.log("The winner is " ++ winner)
285
+
resolve()
286
+
})
287
+
```
288
+
*/
289
+
@scope("Promise")
290
+
@val
291
+
externalany: array<t<'a>> =>t<'a> ="any"
292
+
293
+
/**
294
+
`all(promises)` runs all promises concurrently and returns a promise fulfills when all of the input's promises fulfill, with an array of the fulfillment values. See [`Promise.all`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) on MDN.
`allSettled(promises)` runs all promises concurrently and returns promise fulfills when all of the input's promises settle with an array of objects that describe the outcome of each promise. See [`Promise.allSettled`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) on MDN.
356
+
357
+
```rescript
358
+
open Promise
359
+
360
+
exception TestError(string)
361
+
362
+
let promises = [resolve(1), resolve(2), reject(TestError("some rejected promise"))]
0 commit comments