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

100% Statements 15/15
100% Branches 10/10
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 18109x 18109x 18109x 18109x 171364x 153256x 152139x 153256x   18109x 18108x    
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;
};