setter

Can be used for setting value to object using field path. For example users[index].name.

const values = {users:[{lastName: 'Doe'}]};
const firstUserFirstName = setter('user[0].firstName');

firstUserFirstName(values, 'John');

console.log(values)

// result: {users:[{firstName: 'John', lastName: 'Doe'}]}

Parameters

field string

Returns

any