All files / json-pack/src/json util.ts

100% Statements 15/15
100% Branches 8/8
100% Functions 1/1
100% Lines 11/11

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 9 10 11 12 13 1412x 18080x 18080x 18080x 18080x 171139x 153060x 151913x 153060x   18080x 18079x    
export const findEndingQuote = (uint8: Uint8Array, x: number): number => {
  const len = uint8.length;
  let char = uint8[x];
  let prev = 0;
  while (x < len) {
    if (char === 34 && prev !== 92) break;
    if (char === 92 && prev === 92) prev = 0;
    else prev = char;
    char = uint8[++x];
  }
  if (x === len) throw new Error('Invalid JSON');
  return x;
};