Replaces all occurrences of search with value in source object/array. Comparison is done with Object.is.
If source is exactly the search a value will be returned. It does not do a substring replacements.
Warnings:
By default, it does not mutate the source/deep objects/arrays, but it can be enabled with mutate option.
By default, it does not go into instances for replacement, only plain objects.
If your instances are cross-referenced, you may end up in an infinite loop.
TypeScript users: This is way too dynamic to type properly, therefore, typing assumes the most basic form of
replacement where search and value are of the same type. If that's not the case for you - you'll have to typecast.
replaceDeep<T>(source, search, value, options?): T
Replaces all occurrences of
search
withvalue
insource
object/array. Comparison is done withObject.is
. Ifsource
is exactly thesearch
avalue
will be returned. It does not do a substring replacements.Warnings:
source
/deep objects/arrays, but it can be enabled withmutate
option.TypeScript users: This is way too dynamic to type properly, therefore, typing assumes the most basic form of replacement where search and value are of the same type. If that's not the case for you - you'll have to typecast.