MCPcopy Create free account
hub / github.com/denoland/std / parseBareItem

Function parseBareItem

http/unstable_structured_fields.ts:762–790  ·  view source on GitHub ↗
(state: ParserState)

Source from the content-addressed store, hash-verified

760}
761
762function parseBareItem(state: ParserState): BareItem {
763 const c = peek(state);
764
765 if (c === "-" || isDigit(c)) {
766 return parseIntegerOrDecimal(state);
767 }
768 if (c === '"') {
769 return parseString(state);
770 }
771 if (c === ":") {
772 return parseBinary(state);
773 }
774 if (c === "?") {
775 return parseBoolean(state);
776 }
777 if (c === "@") {
778 return parseDate(state);
779 }
780 if (c === "%") {
781 return parseDisplayString(state);
782 }
783 if (isAlpha(c) || c === "*") {
784 return parseToken(state);
785 }
786
787 throw new SyntaxError(
788 `Invalid structured field: unexpected character '${c}' at position ${state.pos}`,
789 );
790}
791
792function parseIntegerOrDecimal(state: ParserState): BareItem {
793 const { input } = state;

Callers 2

parseItemInternalFunction · 0.85
parseParametersFunction · 0.85

Calls 10

peekFunction · 0.85
isDigitFunction · 0.85
parseIntegerOrDecimalFunction · 0.85
parseStringFunction · 0.85
parseBinaryFunction · 0.85
parseBooleanFunction · 0.85
parseDateFunction · 0.85
parseDisplayStringFunction · 0.85
isAlphaFunction · 0.85
parseTokenFunction · 0.85

Tested by

no test coverage detected