From 7f85122798216dd8c4d1e8ffe74082badbff5051 Mon Sep 17 00:00:00 2001 From: Guga Guichard Date: Wed, 19 Jun 2024 15:16:50 -0300 Subject: [PATCH] docs: Add replaceKeys to the README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 09a18d9..4af9f7e 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ It also only work with common ASCII characters characters. We don't plan to supp - [delimiterKeys](#delimiterkeys) - [kebabKeys](#kebabkeys) - [pascalKeys](#pascalkeys) + - [replaceKeys](#replacekeys) - [snakeKeys](#snakekeys) - [Strongly-typed deep transformation of objects](#strongly-typed-deep-transformation-of-objects) - [deepCamelKeys](#deepcamelkeys) @@ -677,6 +678,22 @@ const result = snakeKeys(data) // ^ { 'hello_world': { 'fooBar': 'baz' } } ``` +### replaceKeys + +This function shallowly transforms the keys of an object by applying [`replace`](#replace) to each of its keys at both runtime and type levels. + +```ts +import { replaceKeys } from 'string-ts' + +const data = { + helloWorld: { + fooBar: 'baz', + }, +} as const +const result = replaceKeys(data, 'o', 'a') +// ^ { 'hellaWorld': { 'fooBar': 'baz' } } +``` + ## Strongly-typed deep transformation of objects ### deepCamelKeys