Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodyowl committed Apr 20, 2024
1 parent cc6829c commit 62cd2a3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/docs/dict.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,30 @@ Contrary to the TS bindings for `Object.values`, the types are refined.
const index = Dict.values({ foo: 1, bar: 2, baz: 3 });
// [1, 2, 3];
```

## Dict.fromOptional(dictOfOptions)

Takes a dict whose values are `Option<unknown>` and returns a dict containing only the values contained in `Some`.

```ts title="Examples"
Dict.fromOptional({
foo: Option.Some(1),
bar: Option.None(),
baz: Option.None(),
});
// {foo: 1}

Dict.fromOptional({
foo: Option.Some(1),
bar: Option.Some(2),
baz: Option.None(),
});
// {foo: 1, bar: 2}

Dict.fromOptional({
foo: Option.None(),
bar: Option.None(),
baz: Option.None(),
});
// {}
```

0 comments on commit 62cd2a3

Please sign in to comment.