Skip to content

Commit 3d2a546

Browse files
docs
1 parent 8cd5d98 commit 3d2a546

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff 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
228229
const a = try something()
229-
const [[ok, err, val]] = [try something()]
230+
231+
// Result is iterable
230232
const [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>

0 commit comments

Comments
 (0)