Skip to content

Commit 53f3e0e

Browse files
committed
chore(docs): mention upperize and lowerize in the mapKeys docs
1 parent 1e3adbd commit 53f3e0e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/object/mapKeys.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ const ra = {
2020
_.mapKeys(ra, key => key.toUpperCase()) // => { MODE, POWER }
2121
_.mapKeys(ra, (key, value) => value) // => { god: 'god', power: 'power' }
2222
```
23+
24+
### Type-safe alternatives
25+
26+
If your goal is to uppercase or lowercase the keys of an object, Radashi provides purpose-built functions for that, called `upperize` and `lowerize`. These functions have better type inference than `mapKeys`.
27+
28+
```ts
29+
import * as _ from 'radashi'
30+
31+
const ra = {
32+
mode: 'god',
33+
power: 'sun',
34+
}
35+
36+
const upperized = _.upperize(ra)
37+
// ^? { MODE: string, POWER: string }
38+
39+
const lowerized = _.lowerize(upperized)
40+
// ^? { mode: string, power: string }
41+
```

0 commit comments

Comments
 (0)