prependToObjectKey
Creates a new object by prepending a specified string to each key of the original object.> prependToObjectKey<T>(obj: T | null | undefined, key: string): PrependToObjectKeyReturn<T>
- (obj:T | null | undefined): (T | undefined): The original object from which keys will be omitted.
- key (string): The string to prepend to each key.
- Returns: A new object with modified keys.
Example
import { omitFromObject } from "@explita/daily-toolset";
const original = { name: 'Alice', age: 30 };
const prepended = prependToObjectKey(original, 'user_');
// Result: { user_name: 'Alice', user_age: 30 }