Appearance
Function: set()
ts
function set(
obj: Record<string, any>,
path: string,
value: any): void;Defined in: src/utils/set.ts:80
Set a value at the specified path of an object. Create the path if it does not exist. Prevent prototype pollution by checking key safety and using safe property assignment.
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | Record<string, any> | The object to modify. |
path | string | A dot-separated string path. |
value | any | The value to set. |
Returns
void
Example
ts
const config = {};
set(config, 'theme.colors.primary', '#3498db');
// config is now { theme: { colors: { primary: '#3498db' } } }