Skip to content

Commit 4a00a62

Browse files
committed
fix: simplify type guard in compareDeepIfVisited — drop redundant isObjectNotArray(a) check
1 parent 65a2823 commit 4a00a62

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/mergeDeep.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ class MergeDeep {
248248
modifications.push({})
249249
additions.push({})
250250
deletions.push({})
251-
if (this.isObjectNotArray(visited[id]) && this.isObjectNotArray(a)) {
251+
// visited[id] may be a primitive string (from the non-object branch in processArrays)
252+
// — only deep-compare when both sides are real objects
253+
if (this.isObjectNotArray(visited[id])) {
252254
// Strip the identity field before comparing — it was already used for matching
253255
const idPropA = NAME_USERNAME_PROPERTY(a)
254256
const idPropV = NAME_USERNAME_PROPERTY(visited[id])

0 commit comments

Comments
 (0)