MCPcopy Create free account
hub / github.com/Noumena-Network/code / diff

Function diff

src/ink/screen.ts:1459–1473  ·  view source on GitHub ↗
(
  prev: Screen,
  next: Screen,
)

Source from the content-addressed store, hash-verified

1457 * Production code should use diffEach() to avoid allocations.
1458 */
1459export function diff(
1460 prev: Screen,
1461 next: Screen,
1462): [point: Point, removed: Cell | undefined, added: Cell | undefined][] {
1463 const output: [Point, Cell | undefined, Cell | undefined][] = []
1464 diffEach(prev, next, (x, y, removed, added) => {
1465 // Copy cells since diffEach reuses the objects
1466 output.push([
1467 { x, y },
1468 removed ? { ...removed } : undefined,
1469 added ? { ...added } : undefined,
1470 ])
1471 })
1472 return output
1473}
1474
1475type DiffCallback = (
1476 x: number,

Callers

nothing calls this directly

Calls 1

diffEachFunction · 0.85

Tested by

no test coverage detected