Skipping properties #50
Replies: 3 comments 1 reply
-
This would be a nice feature but I'm not sure how best to go about implementing it. I want to keep this library functional where possible and thus nothing should rely on or cause side effects. #51 would obviously be an exception to this as margining into an object, mutates that object (and thus isn't functional). However, if this can't nicely be done in a functional way, that doesn't necessarily rule out this feature from being implemented. Currently to do a merge like, you would do it something so: mergeRecords: (values, utils, meta) => {
const valuesWithoutTimestamp = values.map(({ timestamp, ...rest }) => rest);
return utils.defaultMergeFunctions.mergeRecords(valuesWithoutTimestamp, utils, meta);
} |
Beta Was this translation helpful? Give feedback.
-
@RebeccaStevens When you talk about side effects you mean that mergeOthers: (values, utils, meta, options) => {
if (key === "timestamp") {
options.skipProperty();
// Or
options.skipProperty = true;
}
} Things done with |
Beta Was this translation helpful? Give feedback.
-
@NightProgramming Implemented in #64 |
Beta Was this translation helpful? Give feedback.
-
Suppose we don't need any
timestamp
properties on the merge result. Of course we could delete all the properties from the result but we would need to deeply iterate over all objects ourselves.Instead we could just use what deepmerge already provides (deep iteration) + the possibility to skip properties:
Now the merge result should have no
timestamp
property at all.Beta Was this translation helpful? Give feedback.
All reactions