update-with

v4.17.15arrow_drop_down
v4.17.15
v4.17.11
STATUS
Passing
DOWNLOADS
137
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
N/A
This method is like `_.update` except that it accepts `customizer` which is invoked to produce the objects of `path`.
2 contributors
Install update-with as a package?
Copied
npm i @bit/lodash.lodash.update-with
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
updateWith (
object:Object,
path:(Array | string),
updater:Function,
customizer:Function?
) : Object

This method is like update except that it accepts customizer which is invoked to produce the objects of path. If customizer returns undefined path creation is handled by the method instead. The customizer is invoked with three arguments: (nsValue, key, nsObject).

Note: This method mutates object.

Example
const object = {}

updateWith(object, '[0][1]', () => 'a', Object)
// => { '0': { '1': 'a' } }
Arguments
object: Object

The object to modify.

path: (Array | string)

The path of the property to set.

updater: Function

The function to produce the updated value.

customizer: Function?

The function to customize assigned values.

Returns
Object

Returns `object`.

Help and resources