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

Function parseToken

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

Source from the content-addressed store, hash-verified

929}
930
931function parseToken(state: ParserState): BareItem {
932 const first = peek(state);
933 if (!isAlpha(first) && first !== "*") {
934 throw new SyntaxError(
935 `Invalid structured field: invalid token start at position ${state.pos}`,
936 );
937 }
938
939 const startPos = state.pos;
940 state.pos++; // Skip validated first char
941 while (!isEof(state)) {
942 const c = peek(state);
943 if (isTchar(c) || c === ":" || c === "/") {
944 state.pos++;
945 } else {
946 break;
947 }
948 }
949
950 return { type: "token", value: state.input.slice(startPos, state.pos) };
951}
952
953function parseBinary(state: ParserState): BareItem {
954 if (consume(state) !== ":") {

Callers 1

parseBareItemFunction · 0.85

Calls 5

peekFunction · 0.85
isAlphaFunction · 0.85
isEofFunction · 0.85
isTcharFunction · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected