Skip to content

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

ParameterTypeDescription
objRecord<string, any>The object to modify.
pathstringA dot-separated string path.
valueanyThe value to set.

Returns

void

Example

ts
const config = {};
set(config, 'theme.colors.primary', '#3498db');
// config is now { theme: { colors: { primary: '#3498db' } } }

Matterway Assistant SDK Documentation