diff --git a/lib/versioned-map.ts b/lib/versioned-map.ts index 2babcf6..88076bf 100644 --- a/lib/versioned-map.ts +++ b/lib/versioned-map.ts @@ -112,6 +112,8 @@ export default class VersionedMap { prev = v; } + if (prev === NONEXISTENT && !res.delete) return null; + return res; } @@ -122,6 +124,8 @@ export default class VersionedMap { del, ); + if (!mutations) return; + const revisions = []; let prev: V | symbol = NONEXISTENT; @@ -149,7 +153,7 @@ export default class VersionedMap { public *diff(): IterableIterator<[K, V, V]> { for (const [key, revisions] of this.map) { - if (revisions.length === 1) continue; + if (revisions.length <= 1) continue; let first = revisions[0]; let last = revisions[revisions.length - 1]; if (first === NONEXISTENT && last === NONEXISTENT) continue;