Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let trackedActiveIndex = getActiveHistoryEntryIndex(tracked);
let minLength = Math.min(expectedEntries.length, trackedEntries.length);
let firstMismatchedIndex = 0;
for (
firstMismatchedIndex;
firstMismatchedIndex < minLength;
firstMismatchedIndex++
) {
let expectedEntry = expectedEntries[firstMismatchedIndex];
let trackedEntry = trackedEntries[firstMismatchedIndex];
if (!isHistoryEntryEqual(expectedEntry, trackedEntry)) {
break;
}
}
if (
firstMismatchedIndex > lastExpectedIndex &&
(lastExpectedIndex === lastTrackedIndex || lastExpectedIndex === 0)
) {
// 1. Exactly identical.
// 2. Not exactly identical but there's not much that can be done:
// ```
// expected a
// tracked a -> b
// ^ mismatch
// ```
// In this case we cannot remove the extra entries.