MCPcopy Create free account
hub / github.com/chhoumann/quickadd / readTopLevelObjectProperties

Function readTopLevelObjectProperties

src/utils/userScriptSecrets.ts:355–424  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

353}
354
355function readTopLevelObjectProperties(source: string): Map<string, unknown> {
356 const properties = new Map<string, unknown>();
357 let current = 0;
358
359 while (current < source.length) {
360 current = skipWhitespaceAndComments(source, current);
361 if (source[current] === ",") {
362 current += 1;
363 continue;
364 }
365 if (current >= source.length) break;
366
367 const key = readOptionKey(source, current, new Map());
368 if (!key?.name) {
369 current += 1;
370 continue;
371 }
372
373 current = skipWhitespaceAndComments(source, key.end);
374 if (source[current] !== ":") {
375 current += 1;
376 continue;
377 }
378
379 current = skipWhitespaceAndComments(source, current + 1);
380 if (
381 source[current] === "\"" ||
382 source[current] === "'" ||
383 source[current] === "`"
384 ) {
385 const literal = readStringLiteral(source, current);
386 if (!literal) break;
387 properties.set(key.name, literal.value);
388 current = literal.end;
389 continue;
390 }
391
392 if (source.slice(current, current + 4) === "true") {
393 properties.set(key.name, true);
394 current += 4;
395 continue;
396 }
397
398 if (source.slice(current, current + 5) === "false") {
399 properties.set(key.name, false);
400 current += 5;
401 continue;
402 }
403
404 if (source[current] === "{") {
405 const end = findMatchingDelimiter(source, current, "{", "}");
406 if (end === -1) break;
407 current = end + 1;
408 continue;
409 }
410
411 if (source[current] === "[") {
412 const end = findMatchingDelimiter(source, current, "[", "]");

Callers 1

optionBodyDeclaresSecretFunction · 0.85

Calls 5

readOptionKeyFunction · 0.85
readStringLiteralFunction · 0.85
findMatchingDelimiterFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected