I would like to be able to remove a value from my array but with deepmerge the array values only add up. Does anyone have an idea how to solve this problem?
const dp = require('deepmerge');
const a = { moderation: { administrator_roleIds: [ '863696108285591562', '851483467047763978' ] } };
const b = { moderation: { administrator_roleIds: [ '863696108285591562' ] } };
dp(a, b);
// outpout => { moderation: { administrator_roleIds: [ '863696108285591562', '863696108285591562' ] } } or I want { moderation: { administrator_roleIds: [ '863696108285591562' ] } }
I need to use deepmerge because to modify my object I use a function using deepmerge, it would bother me to create another function knowing that I don't know how to do a deepmerge but inverse version of the merge (by removing items).
As per deepmerge definition:
Merges the enumerable properties of two or more objects deeply.
You cant use deepmerge for deleting. Its use case is for merging.
For deleting an element of an array use the normal array methods.
const fruits = ["Banana", "Orange", "Apple", "Mango"];
delete fruits[0];