File tree Expand file tree Collapse file tree 1 file changed +26
-7
lines changed
Expand file tree Collapse file tree 1 file changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -225,16 +225,35 @@ All of its usages are just a combination of the above said rules.
225225</summary >
226226
227227``` js
228+ // wraps the result of `something()` in a Result
228229const a = try something ()
229- const [[ok , err , val ]] = [try something ()]
230+
231+ // Result is iterable
230232const [ok , err , val ] = try something ()
231- array .map (fn => try fn ()) // Result[]
232- yield try something () // yields Result
233- try yield something () // Result<T> where T is iterator().next(T)
234- try await something () // Result<Awaited<T>>
235- try (a instanceof b) // catches TypeError: Right-hand side of 'instanceof' is not an object
233+
234+ // Result still is iterable
235+ const [[ok , err , val ]] = [try something ()]
236+
237+ // Result[]
238+ array .map (fn => try fn ())
239+
240+ // yields Result
241+ yield try something ()
242+
243+ // Result<T> where T is return type of iterator().next()
244+ try yield something ()
245+
246+ // Result<Awaited<ReturnType<typeof something>>>
247+ try await something ()
248+
249+ // catches TypeError: Right-hand side of 'instanceof' is not an object
250+ try (a instanceof b)
251+
252+ // Result<boolean> instanceof boolean
236253(try a) instanceof Result
237- const a = try (try (try (try (try 1 )))) // Result<Result<Result<Result<Result<number>>>
254+
255+ // Result<Result<Result<Result<Result<number>>>
256+ const a = try (try (try (try (try 1 ))))
238257```
239258
240259</details >
You can’t perform that action at this time.
0 commit comments