All files / json-crdt-extensions/peritext/util commonLength.ts

100% Statements 6/6
100% Branches 3/3
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8    57x 2584x 2584x 2584x    
import type {Path} from '@jsonjoy.com/json-pointer';
 
export const commonLength = (a: Path, b: Path): number => {
  let i = 0;
  while (i < a.length && i < b.length && a[i] === b[i]) i++;
  return i;
};