The type of the elements.
The type of the mapped keys.
The original set.
The new set.
An object containing sets of added and deleted elements.
type Point = Readonly<{ x: number; tag: string }>;
const toKey = (point: Point) => JSON.stringify(point);
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
const fromKey = (key: string) => JSON.parse(key) as Point;
const previous = ISetMapped.create<Point, string>(
[
{ x: 1, tag: 'a' },
{ x: 2, tag: 'b' },
],
toKey,
fromKey,
);
const current = ISetMapped.create<Point, string>(
[
{ x: 2, tag: 'b' },
{ x: 3, tag: 'c' },
],
toKey,
fromKey,
);
const { added, deleted } = ISetMapped.diff(previous, current);
assert.deepStrictEqual(Array.from(added), [{ x: 3, tag: 'c' }]);
assert.deepStrictEqual(Array.from(deleted), [{ x: 1, tag: 'a' }]);
Computes the difference between two ISetMapped instances.