ArrayWithOriginalIndices wraps a copy of an old array while moving each item’s original index alongside it. This lets an array-diff algorithm report accurate removals, additions, moves, and unchanged items. section 7.6.4
The wrapper separates four small responsibilities:
- Uses an equalsFn callback, which is important when virtual nodes have equivalent content but different object references. section 7.6.4
Diffing an old and new order
arraysDiffSequence creates the wrapper, scans the new array from left to right, removes obsolete items, records no-ops, adds missing items, moves existing items, and removes leftovers.
