Skip to content

Commit

Permalink
📝 Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaljanocko committed Oct 14, 2022
1 parent 0a5361c commit 519c9d7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ You can either delve into the documentation (highly recommended) or check out so
- [`D.literal`](#dliteral)
- [`D.literalUnion`](#dliteralunion)
- [`D.regex`](#dregex)
-
- [Combinators](#combinators)
- [`D.oneOf`](#doneof)
- [`D.tuple`](#dtuple)
Expand Down Expand Up @@ -243,6 +244,28 @@ With transformation afterwards:
decoder.decode('138').andThen(Number) // 138
```

#### `D.nullable`

If you wrap a decoder in `D.nullable`, then it wither decodes to its supposed type or falls back to `null`.

```ts
const decoder = D.nullable(D.string)

decoder.forceDecoder('hello') // 'hello'
decoder.forceDecoder(null) // null

decoder.forceDecoder(15) // throws DecoderError
```

#### `D.succeed`

This decoder always succesfully decodes to the value provided.

```ts
D.succeed(true).decode('unnecessary string') // true
D.succeed(1234).decode({}) // 1234
```

### Combinators

#### `D.oneOf`
Expand Down

0 comments on commit 519c9d7

Please sign in to comment.