@glutinum/cli 0.14.0 → 0.14.1

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.
Files changed (144) hide show
  1. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  2. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  3. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  4. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  5. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  6. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  7. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  8. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  9. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  10. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  11. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  12. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  13. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  14. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  15. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  16. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  17. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  18. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  19. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  20. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  21. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  22. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  23. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  24. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  25. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  26. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  27. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  28. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  29. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  30. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  31. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  32. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  33. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  34. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  35. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  36. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  37. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  38. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  39. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  40. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  73. package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
  74. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  75. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  76. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  77. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  78. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  79. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  80. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  81. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  82. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  83. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  84. package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
  85. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  86. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  87. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  88. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  89. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  90. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  91. package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
  92. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  93. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  94. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  95. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  96. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  97. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  98. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
  99. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  100. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  101. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  102. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  103. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  104. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  105. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  106. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  115. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  117. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  120. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  124. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  130. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  144. package/package.json +1 -1
@@ -0,0 +1,842 @@
1
+ [<RequireQualifiedAccess>]
2
+ module Promise
3
+
4
+ #nowarn "1182" // Unused values
5
+
6
+ open System
7
+ open Fable.Core
8
+ open Fable.Core.JsInterop
9
+
10
+ /// <summary>
11
+ /// Create a promise from a function
12
+ /// <example>
13
+ /// <code lang="fsharp">
14
+ /// let write (path: string) (content: string) =
15
+ /// Promise.create (fun resolve reject ->
16
+ /// Node.Api.fs.writeFile(path, content, (fun res ->
17
+ /// match res with
18
+ /// | Some res -> reject (res :?> System.Exception)
19
+ /// | None -> resolve ()
20
+ /// ))
21
+ /// )
22
+ /// </code>
23
+ /// </example>
24
+ /// </summary>
25
+ /// <param name="f">
26
+ /// Function used to create the promise, it receives two other function parameters:
27
+ ///
28
+ /// - <c>success</c> : called when the promise is resolved
29
+ /// - <c>fail</c> : called when the promise is rejected
30
+ /// </param>
31
+ /// <typeparam name="'T">Return type of the promise</typeparam>
32
+ /// <returns>
33
+ /// The promise created by the function
34
+ /// </returns>
35
+ [<Emit("new Promise($0)")>]
36
+ let create (f: ('T -> unit) -> (exn -> unit) -> unit) : JS.Promise<'T> = jsNative
37
+
38
+ /// <summary>
39
+ /// Create a promise which wait <c>X</c> ms before resolving.
40
+ /// <example>
41
+ /// <code lang="fsharp">
42
+ /// // Do something
43
+ /// doSomething ()
44
+ /// // Sleep for 1 second
45
+ /// |> Promise.sleep 1000
46
+ /// // Do another thing
47
+ /// |> Promise.map (fun _ ->
48
+ /// doAnotherThing ()
49
+ /// )
50
+ /// |> Promise.map ...
51
+ /// </code>
52
+ /// </example>
53
+ /// </summary>
54
+ /// <param name="ms">Number of milliseconds to wait</param>
55
+ /// <returns>A delayed promise</returns>
56
+ [<Emit("new Promise(resolve => setTimeout(resolve, $0))")>]
57
+ let sleep (ms: int) : JS.Promise<unit> = jsNative
58
+
59
+ /// <summary>
60
+ /// Create a promise (in resolved state) with supplied value.
61
+ /// <example>
62
+ /// <code lang="fsharp">
63
+ /// Promise.lift {| Firstname = "John" |}
64
+ /// |> Promise.map (fun user ->
65
+ /// console.log $"Hello, %s{user.Firstname}"
66
+ /// // Expected output: "Hello, John"
67
+ /// )
68
+ /// |> Promise.map ...
69
+ /// </code>
70
+ /// </example>
71
+ /// </summary>
72
+ /// <param name="a">Value to return</param>
73
+ /// <typeparam name="'T"></typeparam>
74
+ /// <returns>Returns a promise returning the supplied value</returns>
75
+ [<Emit("Promise.resolve($0)")>]
76
+ let lift<'T> (a: 'T) : JS.Promise<'T> = jsNative
77
+
78
+ /// <summary>
79
+ /// Creates promise (in rejected state) with supplied reason.
80
+ /// <example>
81
+ /// <code lang="fsharp">
82
+ /// Promise.reject (Exception "User not found")
83
+ /// |> Promise.map (fun _ ->
84
+ /// // This promise is skipped
85
+ /// )
86
+ /// |> Promise.catch (fun error ->
87
+ /// console.error $"An error ocurred: %s{error.Message}"
88
+ /// // Expected output: "An error ocurred: User not found"
89
+ /// )
90
+ /// |> Promise.map ...
91
+ /// </code>
92
+ /// </example>
93
+ /// </summary>
94
+ /// <param name="reason">Reason to return</param>
95
+ /// <typeparam name="'T"></typeparam>
96
+ /// <returns>Return a promise in a rejected state</returns>
97
+ [<Emit("Promise.reject($0)")>]
98
+ let reject<'T> (reason: exn) : JS.Promise<'T> = jsNative
99
+
100
+ /// <summary>
101
+ /// Bind a value into a promise of a new type.
102
+ /// <example>
103
+ /// <code lang="fsharp">
104
+ /// Promise.lift {| Firstname = "John" |}
105
+ /// |> Promise.bind (fun user ->
106
+ /// // Do something with user and returns a promise
107
+ /// Promise.create (fun resolve reject ->
108
+ /// resolve $"Hello, %s{user.Firstname}"
109
+ /// )
110
+ /// )
111
+ /// |> Promise.map (fun message ->
112
+ /// console.log message
113
+ /// // Expected output: "Hello, John"
114
+ /// )
115
+ /// |> Promise.map ...
116
+ /// </code>
117
+ /// </example>
118
+ /// </summary>
119
+ /// <param name="a">
120
+ /// A function that takes the value of type <c>T1</c> and transforms it into a promise of type <c>T2</c>.
121
+ /// </param>
122
+ /// <param name="pr">The input promise</param>
123
+ /// <typeparam name="'T1"></typeparam>
124
+ /// <typeparam name="'T2"></typeparam>
125
+ /// <returns>A promise of the output type of the binder.</returns>
126
+ [<Emit("$1.then($0)")>]
127
+ let bind (a: 'T1 -> JS.Promise<'T2>) (pr: JS.Promise<'T1>) : JS.Promise<'T2> = jsNative
128
+
129
+ /// <summary>
130
+ /// Map a value into another type, the result will be wrapped in a promise for you.
131
+ /// <example>
132
+ /// <code lang="fsharp">
133
+ /// Promise.lift {| Firstname = "John" |}
134
+ /// |> Promise.map (fun user ->
135
+ /// user.Firstname
136
+ /// ) // Returns a Promise&lt;string&gt; with the value "John"
137
+ /// |> Promise.map ...
138
+ /// </code>
139
+ /// </example>
140
+ /// </summary>
141
+ /// <param name="a">A function to apply to the result of the input promise.</param>
142
+ /// <param name="pr">The input promise</param>
143
+ /// <typeparam name="'T1"></typeparam>
144
+ /// <typeparam name="'T2"></typeparam>
145
+ /// <returns>A promise after applying the mapping function</returns>
146
+ [<Emit("$1.then($0)")>]
147
+ let map (a: 'T1 -> 'T2) (pr: JS.Promise<'T1>) : JS.Promise<'T2> = jsNative
148
+
149
+ /// <summary>
150
+ /// Call a function with the result of a promise and stop the promise chain.
151
+ ///
152
+ /// This is equivalent to <c>Promise.map ... |> ignore</c>
153
+ /// <example>
154
+ /// <code lang="fsharp">
155
+ /// fetchUser ()
156
+ /// |> Promise.iter (fun user ->
157
+ /// console.log "User firstname is user.Firstname"
158
+ /// ) // unit
159
+ /// </code>
160
+ /// </example>
161
+ /// </summary>
162
+ /// <param name="a">A function to apply to the result of the input promise</param>
163
+ /// <param name="pr">The input promise</param>
164
+ /// <typeparam name="'T"></typeparam>
165
+ [<Emit("void ($1.then($0))")>]
166
+ let iter (a: 'T -> unit) (pr: JS.Promise<'T>) : unit = jsNative
167
+
168
+ /// <summary>
169
+ /// This is an identity function, it calls the given function and return the promise value untouched.
170
+ /// <example>
171
+ /// <code lang="fsharp">
172
+ /// fetchUser ()
173
+ /// |> Promise.tap (fun user ->
174
+ /// // Do something
175
+ /// console.log "The user has been received"
176
+ /// )
177
+ /// |> Promise.map (fun user ->
178
+ /// // user value is available here untouched
179
+ /// )
180
+ /// </code>
181
+ /// </example>
182
+ /// </summary>
183
+ /// <param name="fn">A function to call after receiving the receiving of the input promise</param>
184
+ /// <param name="a">The input promise</param>
185
+ /// <typeparam name="'T"></typeparam>
186
+ /// <returns>A promise of the same type as the input promise</returns>
187
+ let tap (fn: 'T -> unit) (a: JS.Promise<'T>) : JS.Promise<'T> =
188
+ a
189
+ |> map (fun x ->
190
+ fn x
191
+ x
192
+ )
193
+
194
+ /// <summary>
195
+ /// Handle an errored promise allowing you pass a return value.
196
+ ///
197
+ /// This version of <c>catch</c> expects a function returning just <c>'T</c>, as opposed to <c>Promise&lt;'T&gt;</c>. If you need to return <c>Promise&lt;'T&gt;</c>, use <c>catchBind</c>.
198
+ /// <example>
199
+ /// <code lang="fsharp">
200
+ /// Promise.create (fun resolve reject ->
201
+ /// reject (System.Exception "User not found")
202
+ /// )
203
+ /// |> Promise.catch (fun error ->
204
+ /// // Log the error
205
+ /// console.error error
206
+ /// // Do something to recover from the error
207
+ /// Error error.Message
208
+ /// )
209
+ /// |> Promise.map ...
210
+ /// </code>
211
+ /// </example>
212
+ /// </summary>
213
+ /// <param name="fail">Function to call if the input promise fail</param>
214
+ /// <param name="pr">The input promise</param>
215
+ /// <typeparam name="'T"></typeparam>
216
+ /// <returns>A promise which result of the call of fail</returns>
217
+ [<Emit("$1.catch($0)")>]
218
+ let catch (fail: exn -> 'T) (pr: JS.Promise<'T>) : JS.Promise<'T> = jsNative
219
+
220
+ /// <summary>
221
+ /// Handle an errored promise allowing to call a promise.
222
+ ///
223
+ /// This version of <c>catch</c> expects a function returning <c>Promise&lt;'T&gt;</c> as opposed to just <c>'T</c>. If you need to return just 'T, use <c>catch</c>.
224
+ /// <example>
225
+ /// <code lang="fsharp">
226
+ /// Promise.create (fun resolve reject ->
227
+ /// reject (System.Exception "User not found")
228
+ /// )
229
+ /// |> Promise.catchBind (fun error ->
230
+ /// // Recover from the error, here we call another promise and returns it's result
231
+ /// logErrorToTheServer error
232
+ /// )
233
+ /// |> Promise.map ...
234
+ /// </code>
235
+ /// </example>
236
+ /// </summary>
237
+ /// <param name="fail">Function to call if the input promise fail</param>
238
+ /// <param name="pr">The input promise</param>
239
+ /// <typeparam name="'T"></typeparam>
240
+ /// <returns>A promise which is the result of the fail function</returns>
241
+ [<Emit("$1.catch($0)")>]
242
+ let catchBind (fail: exn -> JS.Promise<'T>) (pr: JS.Promise<'T>) : JS.Promise<'T> = jsNative
243
+
244
+ /// <summary>
245
+ /// Used to catch errors at the end of a promise chain.
246
+ /// <example>
247
+ /// <code lang="fsharp">
248
+ /// Promise.create (fun resolve reject ->
249
+ /// reject (System.Exception "User not found")
250
+ /// )
251
+ /// |> Promise.map (fun _ ->
252
+ /// // ...
253
+ /// )
254
+ /// |> Promise.map (fun _ ->
255
+ /// // ...
256
+ /// )
257
+ /// |> Promise.catchEnd (fun error ->
258
+ /// // ...
259
+ /// ) // Returns unit
260
+ /// </code>
261
+ /// </example>
262
+ /// </summary>
263
+ /// <param name="fail">Fuction to call if the input promise fail</param>
264
+ /// <param name="pr">The input promise</param>
265
+ /// <typeparam name="'T"></typeparam>
266
+ [<Emit("void ($1.catch($0))")>]
267
+ let catchEnd (fail: exn -> unit) (pr: JS.Promise<'T>) : unit = jsNative
268
+
269
+ /// <summary>
270
+ /// A combination of <c>map</c> and <c>catch</c>, this function applies the <c>success</c> continuation when the input promise resolves successfully, or <c>fail</c> continuation when the input promise fails.
271
+ /// <example>
272
+ /// <code lang="fsharp">
273
+ /// somePromise
274
+ /// |> Promise.either
275
+ /// (fun x -> string x)
276
+ /// (fun err -> Promise.lift err.Message)
277
+ /// |> Promise.map ...
278
+ /// </code>
279
+ /// </example>
280
+ /// </summary>
281
+ /// <param name="success">Function to call if the input promise succeeds</param>
282
+ /// <param name="fail">Function to call if the input promise fail</param>
283
+ /// <param name="pr">The input promise</param>
284
+ /// <typeparam name="'T1"></typeparam>
285
+ /// <typeparam name="'T2"></typeparam>
286
+ /// <returns>A new promise which is the result of calling <c>success</c> if <c>pr</c> succeedes, or of <c>fail</c> if <c>pr</c> failed</returns>
287
+ [<Emit("$2.then($0).catch($1)")>]
288
+ let either (success: 'T1 -> 'T2) (fail: exn -> 'T2) (pr: JS.Promise<'T1>) : JS.Promise<'T2> =
289
+ jsNative
290
+
291
+ /// <summary>
292
+ /// A combination of <c>bind</c> and <c>catchBind</c>, this function applies the <c>success</c> continuation when the input promise resolves successfully, or <c>fail</c> continuation when the input promise fails.
293
+ /// <example>
294
+ /// <code lang="fsharp">
295
+ /// somePromise
296
+ /// |> Promise.eitherBind
297
+ /// (fun x -> string x |> Promise.lift)
298
+ /// (fun err -> Promise.lift err.Message)
299
+ /// |> Promise.map ...
300
+ /// </code>
301
+ /// </example>
302
+ /// </summary>
303
+ /// <param name="success">Binder function to call if the input promise succeeds</param>
304
+ /// <param name="fail">Binder function to call if the input promise fail</param>
305
+ /// <param name="pr">The input promise</param>
306
+ /// <typeparam name="'T1"></typeparam>
307
+ /// <typeparam name="'T2"></typeparam>
308
+ /// <returns>A new promise which is the result of calling <c>success</c> if <c>pr</c> succeedes, or of <c>fail</c> if <c>pr</c> failed</returns>
309
+ [<Emit("$2.then($0).catch($1)")>]
310
+ let eitherBind
311
+ (success: 'T1 -> JS.Promise<'T2>)
312
+ (fail: exn -> JS.Promise<'T2>)
313
+ (pr: JS.Promise<'T1>)
314
+ : JS.Promise<'T2>
315
+ =
316
+ jsNative
317
+
318
+ /// <summary>
319
+ /// Same as <c>Promise.either</c> but stopping the promise execution.
320
+ /// <example>
321
+ /// <code lang="fsharp">
322
+ /// somePromise
323
+ /// |> Promise.eitherEnd
324
+ /// (fun x -> string x)
325
+ /// (fun err -> Promise.lift err.Message)
326
+ /// </code>
327
+ /// </example>
328
+ /// </summary>
329
+ /// <param name="success">Binder function to call if the input promise succeeds</param>
330
+ /// <param name="fail">Binder function to call if the input promise fail</param>
331
+ /// <param name="pr">The input promise</param>
332
+ /// <typeparam name="'T"></typeparam>
333
+ [<Emit("void ($2.then($0).catch($1))")>]
334
+ let eitherEnd (success: 'T -> unit) (fail: exn -> unit) (pr: JS.Promise<'T>) : unit = jsNative
335
+
336
+ /// <summary>
337
+ /// Start a promise.
338
+ ///
339
+ /// Fake starting a promise. It is faking it because promise are hot meaning they execute directly after their creation.
340
+ ///
341
+ /// <c>Promise.start</c> is equivalent to <c>promise |> ignore</c>
342
+ ///
343
+ /// <example>
344
+ /// <code lang="fsharp">
345
+ /// myPromise
346
+ /// |> Promise.start
347
+ /// </code>
348
+ /// </example>
349
+ /// </summary>
350
+ /// <param name="pr">The input promise</param>
351
+ /// <typeparam name="'T"></typeparam>
352
+ [<Emit("void $0")>]
353
+ let start (pr: JS.Promise<'T>) : unit = jsNative
354
+
355
+ /// <summary>
356
+ /// Same as <c>Promise.start</c> but forcing you to handle the rejected state.
357
+ /// <example>
358
+ /// <code lang="fsharp">
359
+ /// myPromise
360
+ /// |> Promise.tryStart
361
+ /// (fun error ->
362
+ /// // Do something on error
363
+ /// )
364
+ /// </code>
365
+ /// </example>
366
+ /// </summary>
367
+ /// <param name="fail">Function to apply if the promise fail</param>
368
+ /// <param name="pr">The input promise</param>
369
+ /// <typeparam name="'T"></typeparam>
370
+ [<Emit("$1.catch($0)")>]
371
+ let tryStart (fail: exn -> unit) (pr: JS.Promise<'T>) : unit = jsNative
372
+
373
+ /// <summary>
374
+ /// Takes a sequence of promises as an input, and returns a single <c>Promise</c> that resolves to an array of the results of the input promises.
375
+ /// <example>
376
+ /// <code lang="fsharp">
377
+ /// let p1 =
378
+ /// promise {
379
+ /// do! Promise.sleep 100
380
+ /// return 1
381
+ /// }
382
+ /// let p2 =
383
+ /// promise {
384
+ /// do! Promise.sleep 200
385
+ /// return 2
386
+ /// }
387
+ /// let p3 =
388
+ /// promise {
389
+ /// do! Promise.sleep 300
390
+ /// return 3
391
+ /// }
392
+ ///
393
+ /// Promise.Parallel [p1; p2; p3]
394
+ /// |> Promise.map (fun res ->
395
+ /// // res = [|1; 2; 3 |]
396
+ /// )
397
+ /// |> Promise.map ...
398
+ /// </code>
399
+ /// </example>
400
+ /// </summary>
401
+ /// <param name="pr">A list of promise to wait for</param>
402
+ /// <typeparam name="'T"></typeparam>
403
+ /// <returns>Return a new promise returning an array containing all the promise result</returns>
404
+ [<Emit("Promise.all($0)")>]
405
+ let Parallel (pr: seq<JS.Promise<'T>>) : JS.Promise<'T[]> = jsNative
406
+
407
+ /// <summary>
408
+ /// Takes a sequence of promises as an input, and returns a single <c>Promise</c> that resolves to an array of the results of the input promises.
409
+ /// <example>
410
+ /// <code lang="fsharp">
411
+ /// let p1 =
412
+ /// promise {
413
+ /// do! Promise.sleep 100
414
+ /// return 1
415
+ /// }
416
+ /// let p2 =
417
+ /// promise {
418
+ /// do! Promise.sleep 200
419
+ /// return 2
420
+ /// }
421
+ /// let p3 =
422
+ /// promise {
423
+ /// do! Promise.sleep 300
424
+ /// return 3
425
+ /// }
426
+ ///
427
+ /// Promise.all [p1; p2; p3]
428
+ /// |> Promise.map (fun res ->
429
+ /// // res = [|1; 2; 3 |]
430
+ /// )
431
+ /// |> Promise.map ...
432
+ /// </code>
433
+ /// </example>
434
+ ///
435
+ /// Note: If you need to return mixed types you can use boxing and unboxing
436
+ ///
437
+ /// <example>
438
+ /// <code lang="fsharp">
439
+ /// let users =
440
+ /// promise {
441
+ /// let! users = fetchUsers ()
442
+ /// return box users
443
+ /// }
444
+ /// let posts =
445
+ /// promise {
446
+ /// let! posts = fetchPosts ()
447
+ /// return box posts
448
+ /// }
449
+ ///
450
+ /// Promise.all [p1; p2]
451
+ /// |> Promise.map (fun res ->
452
+ /// let users = unbox&lt;User list&gt; res.[0]
453
+ /// let posts = unbox&lt;Post list&gt; res.[1]
454
+ /// // ...
455
+ /// )
456
+ /// </code>
457
+ /// </example>
458
+ /// </summary>
459
+ /// <param name="pr">A list of promise to wait for</param>
460
+ /// <typeparam name="'T"></typeparam>
461
+ /// <returns>Return a new promise returning an array containing all the promise result</returns>
462
+ [<Emit("Promise.all($0)")>]
463
+ let all (pr: seq<JS.Promise<'T>>) : JS.Promise<'T[]> = jsNative
464
+
465
+ [<StringEnum>]
466
+ type SettledStatus =
467
+ | Fulfilled
468
+ | Rejected
469
+
470
+ type SettledValue<'T> =
471
+ abstract status: SettledStatus
472
+ abstract value: 'T option
473
+ abstract reason: exn option
474
+
475
+ /// <summary>
476
+ /// The Promise.allSettled function returns a promise that resolves after all of the given promises have either
477
+ /// fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
478
+ /// It is typically used when you have multiple asynchronous tasks that are not dependent on one another to complete successfully,
479
+ /// or you'd always like to know the result of each promise.
480
+ /// In comparison, the Promise returned by Promise.all may be more appropriate if the tasks are dependent
481
+ /// on each other / if you'd like to immediately reject upon any of them rejecting.
482
+ /// </summary>
483
+ /// <param name="pr">A list of promise to wait for</param>
484
+ /// <typeparam name="'T"></typeparam>
485
+ /// <example>
486
+ /// <code lang="fsharp">
487
+ /// let success =
488
+ /// promise {
489
+ /// do! Promise.sleep 100
490
+ /// return 1
491
+ /// }
492
+ /// let rejection = Promise.reject (exn "I Failed")
493
+ ///
494
+ /// Promise.allSettled [success; rejection]
495
+ /// |> Promise.map(fun values ->
496
+ /// let success = values.[0]
497
+ /// let rejection = values.[1]
498
+ /// success.value.Value |> equal 1
499
+ /// rejection.reason.Value.Message |> equal "I Failed"
500
+ /// )
501
+ /// </code>
502
+ /// </example>
503
+ [<Emit("Promise.allSettled($0)")>]
504
+ let allSettled (pr: seq<JS.Promise<'T>>) : JS.Promise<SettledValue<'T>[]> = jsNative
505
+
506
+ /// <summary>
507
+ /// Promise.any takes an iterable of Promise objects.
508
+ /// It returns a single promise that resolves as soon as
509
+ /// any of the promises in the iterable fulfills,
510
+ /// with the value of the fulfilled promise. If no promises in the iterable fulfill
511
+ /// (if all of the given promises are rejected),
512
+ /// then the returned promise is rejected with an AggregateError,
513
+ /// a new subclass of Error that groups together individual errors.
514
+ /// </summary>
515
+ /// <param name="pr">A list of promise to wait for</param>
516
+ /// <typeparam name="'T"></typeparam>
517
+ /// <example>
518
+ /// <code lang="fsharp">
519
+ /// let success() =
520
+ /// promise {
521
+ /// do! Promise.sleep 100
522
+ /// return 1
523
+ /// }
524
+ /// let rejection() = Promise.reject (exn "I Failed")
525
+ /// let rejection2() =
526
+ /// promise {
527
+ /// do! Promise.sleep 50
528
+ /// return! Promise.reject (exn "I Failed")
529
+ /// }
530
+ ///
531
+ /// Promise.any [rejection(); rejection2(); success()]
532
+ /// |> Promise.map (fun result ->
533
+ /// result |> equal 1
534
+ /// )
535
+ /// </code>
536
+ /// </example>
537
+ [<Emit("Promise.any($0)")>]
538
+ let any (pr: seq<JS.Promise<'T>>) : JS.Promise<'T> = jsNative
539
+
540
+ /// <summary>
541
+ /// The Promise.race method returns a promise that fulfills or
542
+ /// rejects as soon as one of the promises in an iterable fulfills or rejects,
543
+ /// with the value or reason from that promise.
544
+ /// </summary>
545
+ /// <example>
546
+ /// <code lang="fsharp">
547
+ /// let success() =
548
+ /// promise {
549
+ /// do! Promise.sleep 5
550
+ /// return 1
551
+ /// }
552
+ /// let rejection() =
553
+ /// promise {
554
+ /// do! Promise.sleep 10
555
+ /// return! Promise.reject (exn "I Failed First")
556
+ /// }
557
+ /// let rejection2() =
558
+ /// promise {
559
+ /// do! Promise.sleep 50
560
+ /// return! Promise.reject (exn "I Failed Last")
561
+ /// }
562
+ ///
563
+ /// Promise.race [rejection2(); rejection(); success()]
564
+ /// |> Promise.map(fun result ->
565
+ /// result |> equal 1
566
+ /// )
567
+ /// </code>
568
+ /// </example>
569
+ [<Emit("Promise.race($0)")>]
570
+ let race (pr: seq<JS.Promise<'T>>) : JS.Promise<'T> = jsNative
571
+
572
+ /// <summary>
573
+ /// Map the <c>Promise</c> result into a <c>Result</c> type.
574
+ /// <example>
575
+ /// <code lang="fsharp">
576
+ /// Success example
577
+ /// Promise.lift 42
578
+ /// |> Promise.result
579
+ /// |> Promise.map (fun value ->
580
+ /// // value = Ok 42
581
+ /// )
582
+ ///
583
+ /// // Fail example
584
+ /// Promise.reject "Invalid value"
585
+ /// |> Promise.result
586
+ /// |> Promise.map (fun value ->
587
+ /// // value = Error "Invalid value"
588
+ /// )
589
+ /// </code>
590
+ /// </example>
591
+ /// </summary>
592
+ /// <param name="a">The input promise</param>
593
+ /// <typeparam name="'T"></typeparam>
594
+ /// <returns>A promise returning <c>Ok</c> if the input promise succeed, <c>Error</c> if the input promise failed</returns>
595
+ let result (a: JS.Promise<'T>) : JS.Promise<Result<'T, exn>> = either Ok Error a
596
+
597
+ /// <summary>
598
+ /// Evaluates to `myPromise |> Promise.map (Result.map fn)`
599
+ /// <example>
600
+ /// <code lang="fsharp">
601
+ /// Promise.lift 42
602
+ /// |> Promise.result
603
+ /// |> Promise.mapResult (fun value ->
604
+ /// value + 10
605
+ /// )
606
+ /// |> Promise.map (fun value ->
607
+ /// // value = Ok 52
608
+ /// )
609
+ /// </code>
610
+ /// </example>
611
+ /// </summary>
612
+ /// <param name="fn">The mapping function</param>
613
+ /// <param name="a">The input promise</param>
614
+ /// <typeparam name="'T1"></typeparam>
615
+ /// <typeparam name="'T2"></typeparam>
616
+ /// <typeparam name="'E"></typeparam>
617
+ /// <returns>A promise returning the result of applying the mapping function to the input promise result</returns>
618
+ let mapResult (fn: 'T1 -> 'T2) (a: JS.Promise<Result<'T1, 'E>>) : JS.Promise<Result<'T2, 'E>> =
619
+ a |> map (Result.map fn)
620
+
621
+ /// <summary>
622
+ /// Transform the success part of a result promise into another promise.
623
+ /// <example>
624
+ /// <code lang="fsharp">
625
+ /// let multiplyBy2 (value : int) =
626
+ /// Promise.create (fun resolve reject ->
627
+ /// resolve (value * 2)
628
+ /// )
629
+ ///
630
+ /// Promise.lift 42
631
+ /// |> Promise.result
632
+ /// |> Promise.bindResult (fun value ->
633
+ /// multiplyBy2 value
634
+ /// )
635
+ /// |> Promise.map (fun value ->
636
+ /// // value = Ok 84
637
+ /// )
638
+ /// </code>
639
+ /// </example>
640
+ /// </summary>
641
+ /// <param name="fn">The binder function</param>
642
+ /// <param name="a">The input promise</param>
643
+ /// <typeparam name="'T1"></typeparam>
644
+ /// <typeparam name="'T2"></typeparam>
645
+ /// <typeparam name="'E"></typeparam>
646
+ /// <returns>Returns a new promise applying to the binder function to it if the input promise succeed</returns>
647
+ let bindResult
648
+ (fn: 'T1 -> JS.Promise<'T2>)
649
+ (a: JS.Promise<Result<'T1, 'E>>)
650
+ : JS.Promise<Result<'T2, 'E>>
651
+ =
652
+ a
653
+ |> bind (fun a ->
654
+ match a with
655
+ | Ok a -> fn a |> map Ok
656
+ | Error e -> lift (Error e)
657
+ )
658
+
659
+ /// <summary>
660
+ /// Evaluates to <c>myPromise |> Promise.map (Result.map fn)</c>
661
+ /// <example>
662
+ /// <code lang="fsharp">
663
+ /// Promise.reject -1
664
+ /// |> Promise.result
665
+ /// |> Promise.mapResultError (fun value ->
666
+ /// $"%s{value} is not a valid value"
667
+ /// )
668
+ /// |> Promise.map (fun value ->
669
+ /// // value = Error "-1 is not a valid value"
670
+ /// )
671
+ /// </code>
672
+ /// </example>
673
+ /// </summary>
674
+ /// <param name="fn">A mapper function</param>
675
+ /// <param name="a">The input promise</param>
676
+ /// <typeparam name="'E1"></typeparam>
677
+ /// <typeparam name="'E2"></typeparam>
678
+ /// <typeparam name="'T"></typeparam>
679
+ /// <returns>A promise returning the result of applying the mapper function to the input promise in case of error, otherwise the result of the input promise as it is</returns>
680
+ let mapResultError (fn: 'E1 -> 'E2) (a: JS.Promise<Result<'T, 'E1>>) : JS.Promise<Result<'T, 'E2>> =
681
+ a |> map (Result.mapError fn)
682
+
683
+ /// <summary>
684
+ /// A builder to provide promise Computation Expression support.
685
+ ///
686
+ /// The CE is available via <c>promise { ... }</c>
687
+ /// <example>
688
+ /// <code lang="fsharp">
689
+ /// let double (value : int) =
690
+ /// promise {
691
+ /// return value * 2
692
+ /// }
693
+ /// </code>
694
+ /// </example>
695
+ /// </summary>
696
+ type PromiseBuilder() =
697
+ [<Emit("$1.then($2)")>]
698
+ member _.Bind(p: JS.Promise<'T1>, f: 'T1 -> JS.Promise<'T2>) : JS.Promise<'T2> = jsNative
699
+
700
+ [<Emit("$1.then(() => $2)")>]
701
+ member _.Combine(p1: JS.Promise<unit>, p2: JS.Promise<'T>) : JS.Promise<'T> = jsNative
702
+
703
+ member _.For(seq: seq<'T>, body: 'T -> JS.Promise<unit>) : JS.Promise<unit> =
704
+ // (lift (), seq)
705
+ // ||> Seq.fold (fun p a ->
706
+ // bind (fun () -> body a) p)
707
+ let mutable p = lift ()
708
+
709
+ for a in seq do
710
+ p <- p |> bind (fun () -> body a)
711
+
712
+ p
713
+
714
+ [<Emit("$1.then($2)")>]
715
+ member _.For(p: JS.Promise<'T1>, f: 'T1 -> JS.Promise<'T2>) : JS.Promise<'T2> = jsNative
716
+
717
+ member this.While(guard: unit -> bool, p: JS.Promise<unit>) : JS.Promise<unit> =
718
+ if guard () then
719
+ bind (fun () -> this.While(guard, p)) p
720
+ else
721
+ lift ()
722
+
723
+ [<Emit("Promise.resolve($1)")>]
724
+ member _.Return(a: 'T) : JS.Promise<'T> = jsNative
725
+
726
+ [<Emit("$1")>]
727
+ member _.ReturnFrom(p: JS.Promise<'T>) : JS.Promise<'T> = jsNative
728
+
729
+ [<Emit("Promise.resolve()")>]
730
+ member _.Zero() : JS.Promise<unit> = jsNative
731
+
732
+ member _.TryFinally(p: JS.Promise<'T>, compensation: unit -> unit) : JS.Promise<'T> =
733
+ either
734
+ (fun (x: 'T) ->
735
+ compensation ()
736
+ x
737
+ )
738
+ (fun er ->
739
+ compensation ()
740
+ raise er
741
+ )
742
+ p
743
+
744
+ [<Emit("$1.catch($2)")>]
745
+ member _.TryWith(p: JS.Promise<'T>, catchHandler: exn -> JS.Promise<'T>) : JS.Promise<'T> =
746
+ jsNative
747
+
748
+ // Delay must generate a cold promise-like object that re-runs every time it's called,
749
+ // so we cannot use the JS Promise constructor which is stateful
750
+ member _.Delay(generator: unit -> JS.Promise<'T>) : JS.Promise<'T> =
751
+ !!
752
+ createObj
753
+ [
754
+ "then"
755
+ ==> fun onSuccess onError ->
756
+ try
757
+ generator().``then``(onSuccess, onError)
758
+ with er ->
759
+ if isNull (box onError) then
760
+ reject er
761
+ else
762
+ try
763
+ onError er |> lift
764
+ with er ->
765
+ reject er
766
+ "catch"
767
+ ==> fun onError ->
768
+ try
769
+ generator().catch(onError)
770
+ with er ->
771
+ try
772
+ onError er |> lift
773
+ with er ->
774
+ reject er
775
+ ]
776
+
777
+ // Make sure we call `then` because this may be used with "cold" fake promises generated by Delay
778
+ member _.Run(p: JS.Promise<'T>) : JS.Promise<'T> = p.``then`` (id)
779
+
780
+ member this.Using<'T1, 'T2 when 'T1 :> IDisposable>
781
+ (resource: 'T1, binder: 'T1 -> JS.Promise<'T2>)
782
+ : JS.Promise<'T2>
783
+ =
784
+ this.TryFinally(binder (resource), fun () -> resource.Dispose())
785
+
786
+ [<Emit("Promise.all([$1, $2])")>]
787
+ member _.MergeSources(a: JS.Promise<'T1>, b: JS.Promise<'T2>) : JS.Promise<'T1 * 'T2> = jsNative
788
+
789
+ [<Emit("Promise.all([$1, $2, $3])")>]
790
+ member _.MergeSources3
791
+ (a: JS.Promise<'T1>, b: JS.Promise<'T2>, c: JS.Promise<'T3>)
792
+ : JS.Promise<'T1 * 'T2 * 'T3>
793
+ =
794
+ jsNative
795
+
796
+ [<Emit("Promise.all([$1, $2, $3, $4])")>]
797
+ member _.MergeSources4
798
+ (a: JS.Promise<'T1>, b: JS.Promise<'T2>, c: JS.Promise<'T3>, d: JS.Promise<'T4>)
799
+ : JS.Promise<'T1 * 'T2 * 'T3 * 'T4>
800
+ =
801
+ jsNative
802
+
803
+ [<Emit("Promise.all([$1, $2, $3, $4, $5])")>]
804
+ member _.MergeSources5
805
+ (
806
+ a: JS.Promise<'T1>,
807
+ b: JS.Promise<'T2>,
808
+ c: JS.Promise<'T3>,
809
+ d: JS.Promise<'T4>,
810
+ e: JS.Promise<'T5>
811
+ )
812
+ : JS.Promise<'T1 * 'T2 * 'T3 * 'T4 * 'T5>
813
+ =
814
+ jsNative
815
+
816
+ [<Emit("Promise.all([$1, $2, $3, $4, $5, $6])")>]
817
+ member _.MergeSources6
818
+ (
819
+ a: JS.Promise<'T1>,
820
+ b: JS.Promise<'T2>,
821
+ c: JS.Promise<'T3>,
822
+ d: JS.Promise<'T4>,
823
+ e: JS.Promise<'T5>,
824
+ f: JS.Promise<'T6>
825
+ )
826
+ : JS.Promise<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6>
827
+ =
828
+ jsNative
829
+
830
+ // member _.BindReturn(y: JS.Promise<'T1>, f) = map f y
831
+
832
+ [<Emit("Promise.all([$1,$2]).then(([a,b]) => $3(a,b))")>]
833
+ [<CustomOperation("andFor", IsLikeZip = true)>]
834
+ member _.Merge
835
+ (
836
+ a: JS.Promise<'T1>,
837
+ b: JS.Promise<'T2>,
838
+ [<ProjectionParameter>] resultSelector: 'T1 -> 'T2 -> 'R
839
+ )
840
+ : JS.Promise<'R>
841
+ =
842
+ jsNative