Sorry if am posting in the wrong place.
I am looking for a variant of omit function that support nested properties. Example:
var obj = {a:{b:{c:1,d:2}};
var res = _.omit(obj, 'a.b.d'); // res = {a:{b:{c:1}}
Does it already exist? If not, how complicated is it to implement?
Thanks.
This doesn't exist in lodash. It would be similar to a merge but with a list of properties to skip. At the moment we don't have a way, even with the customizer, to skip a property assignment.
I'll keep an eye on demand for this feature in the future.
In lodash v4+ we have an _.unset method which is similar to objectPath.del.
For an immutable flavor of unset you can use the fp modules as
require('lodash/fp').unset or require('lodash/fp/unset')
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
In lodash v4+ we have an
_.unsetmethod which is similar toobjectPath.del.For an immutable flavor of
unsetyou can use the fp modules asrequire('lodash/fp').unsetorrequire('lodash/fp/unset')