Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ export default function diff(
(!options.cyclesFix || !_stack.includes(value))
) {
// Recurse into objects and arrays
diffs.push.apply(
diffs,
diff(
value,
newValue,
options,
options.cyclesFix ? _stack.concat([value]) : [],
).map((difference) => {
difference.path.unshift(path);
return difference;
}),
);
if (options.cyclesFix) {
_stack.push(value);
}

const subDiffs = diff(value, newValue, options, _stack);

if (options.cyclesFix) {
_stack.pop();
}

for (const subDiff of subDiffs) {
subDiff.path.unshift(path);
diffs.push(subDiff);
}
} else if (
!(
Object.is(value, newValue) /* treat nulls as equivalent */ ||
Expand Down