util.js 590 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.findEndingQuote = void 0;
  4. const findEndingQuote = (uint8, x) => {
  5. const len = uint8.length;
  6. let char = uint8[x];
  7. let prev = 0;
  8. while (x < len) {
  9. if (char === 34 && prev !== 92)
  10. break;
  11. if (char === 92 && prev === 92)
  12. prev = 0;
  13. else
  14. prev = char;
  15. char = uint8[++x];
  16. }
  17. if (x === len)
  18. throw new Error('Invalid JSON');
  19. return x;
  20. };
  21. exports.findEndingQuote = findEndingQuote;
  22. //# sourceMappingURL=util.js.map