Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
inaiat committed Apr 15, 2024
1 parent 422f3f1 commit a2d115b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BUILD_SHA
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d3c9909935d9336f9c9848a07af4255c795a0915
422f3f1317b2cc9d0a82c587968241f846137894
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ For asynchronous tasks, `resultar` offers a `ResultAsync` class which wraps a `P
- [`ResultAsync.andThen` (method)](#resultasyncandthen-method)
- [`ResultAsync.orElse` (method)](#resultasyncorelse-method)
- [`ResultAsync.tap` (method)](#resultasynctap-method)
- [`ResultAsync.finally` (method)](#resultasyncfinally-method)
- [`ResultAsync.match` (method)](#resultasyncmatch-method)
- [`ResultAsync.combine` (static class method)](#resultasynccombine-static-class-method)
- [`ResultAsync.combineWithAllErrors` (static class method)](#resultasynccombinewithallerrors-static-class-method)
Expand Down Expand Up @@ -1093,10 +1094,42 @@ class ResultAsync<T, E> {
}
```
**Example:**
See [`Result.tap` (method)](#resulttap-method)
[⬆️ Back to top](#toc)
---
#### `ResultAsync.finally` (method)
Executes a cleanup function wether the is ok or error. This method is usefull to cleanup resources for async operations.
**Signature:**
```typescript
class ResultAsync<T, E> {
finally(f: (value: T, error: E) => void): DisposableResultAsync<T, E> {...}
}
```
**Example:**
```typescript
const fileHandle = await fs.open('foo.txt', 'w')

const result
= await fromPromise(fileHandle.write('A new line of text'), String)
.finally(async () => {
console.info('Closing file handle')
await fileHandle.close()
})

if (result.isOk()) {
console.log(result.value) // == 'A new line of text'
}

```
[⬆️ Back to top](#toc)
---
Expand Down

0 comments on commit a2d115b

Please sign in to comment.