MCPcopy Create free account
hub / github.com/denoland/std / #parseString

Method #parseString

jsonc/parse.ts:296–312  ·  view source on GitHub ↗
(value: {
    type: "String";
    sourceText: string;
    position: number;
  })

Source from the content-addressed store, hash-verified

294 }
295
296 #parseString(value: {
297 type: "String";
298 sourceText: string;
299 position: number;
300 }): string {
301 let parsed;
302 try {
303 // Use JSON.parse to handle `\u0000` etc. correctly.
304 parsed = JSON.parse(value.sourceText);
305 } catch {
306 throw new SyntaxError(buildErrorMessage(value));
307 }
308 if (typeof parsed !== "string") {
309 throw new TypeError(`Parsed value is not a string: ${parsed}`);
310 }
311 return parsed;
312 }
313
314 #parseNullOrTrueOrFalseOrNumber(value: {
315 type: "NullOrTrueOrFalseOrNumber";

Callers 2

#parseJsonValueMethod · 0.95
#parseObjectMethod · 0.95

Calls 2

buildErrorMessageFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected