Closed kanongil closed 4 years ago
Smart.
The clone() change is a breaking change because if a value is used by more than one key, and you only shallow one, the other one will now also be shallow. This is fine for all my use cases but it is a breaking change.
I need to review the applyToDefaults() change more closely.
This patch refactors the shallow handling of
clone()
andapplyToDefaults()
to avoid temporarily modifying the source object, and setting properties on the target object multiple times.The handling is done in a simple and effective manner by pre-filling a
seen
Map()
that is passed to the internal call toclone()
.This new handling should also increase the performance of shallow copies.