File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff 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) =>
14821483console .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 `
You can’t perform that action at this time.
0 commit comments