Skip to content

Commit 27f8749

Browse files
committed
docs: add P.object on README.md
1 parent ccb52b5 commit 27f8749

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ TS-Pattern assumes that [Strict Mode](https://www.typescriptlang.org/tsconfig#st
133133
- [`P.intersection` patterns](#pintersection-patterns)
134134
- [`P.string` predicates](#pstring-predicates)
135135
- [`P.number` and `P.bigint` predicates](#pnumber-and-pbigint-predicates)
136+
- [`P.object` predicates](#pobject-predicates)
136137
- [Types](#types)
137138
- [`P.infer`](#pinfer)
138139
- [`P.Pattern`](#pPattern)
@@ -1482,6 +1483,23 @@ const fn = (input: number) =>
14821483
console.log(fn(-3.141592), fn(7)); // logs '✅ ❌'
14831484
```
14841485

1486+
## `P.object` predicates
1487+
1488+
`P.object` has a number of methods to help you match on specific object.
1489+
1490+
### `P.object.empty`
1491+
1492+
`P.object.empty` matches empty object
1493+
1494+
```ts
1495+
const fn = (input: string) =>
1496+
match(input)
1497+
.with(P.object.empty(), () => 'Empty!')
1498+
.otherwise(() => 'Full!');
1499+
1500+
console.log(fn('{}')); // Empty
1501+
```
1502+
14851503
## Types
14861504

14871505
### `P.infer`

0 commit comments

Comments
 (0)