mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 17:23:37 +08:00
refactor(capture): reuse JSON slice detachment (#17335)
This commit is contained in:
@@ -34,13 +34,6 @@ const detachSlice = (
|
||||
return Buffer.from(text.slice(start, end), encoding).toString(encoding);
|
||||
};
|
||||
|
||||
const detachAsciiSlice = (text: string, start: number, end: number): string => {
|
||||
const length = end - start;
|
||||
if (length === 0) return "";
|
||||
if (length < 13) return text.slice(start, end);
|
||||
return Buffer.from(text.slice(start, end), "latin1").toString("latin1");
|
||||
};
|
||||
|
||||
const setOwnProperty = (
|
||||
target: Record<string, unknown>,
|
||||
key: string,
|
||||
@@ -278,7 +271,7 @@ class StrictCaptureJsonParser {
|
||||
this.#readDigits();
|
||||
}
|
||||
if (skip) return;
|
||||
return new LosslessNumber(detachAsciiSlice(text, start, this.#pos));
|
||||
return new LosslessNumber(detachSlice(text, start, this.#pos, true));
|
||||
}
|
||||
|
||||
expectKeyword(word: "true" | "false" | "null"): void {
|
||||
|
||||
Reference in New Issue
Block a user