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

Function parseBoolean

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

Source from the content-addressed store, hash-verified

990}
991
992function parseBoolean(state: ParserState): BareItem {
993 if (consume(state) !== "?") {
994 throw new SyntaxError(
995 `Invalid structured field: expected '?' at position ${state.pos - 1}`,
996 );
997 }
998
999 const c = consume(state);
1000 if (c === "1") {
1001 return { type: "boolean", value: true };
1002 }
1003 if (c === "0") {
1004 return { type: "boolean", value: false };
1005 }
1006
1007 throw new SyntaxError(
1008 `Invalid structured field: expected '0' or '1' at position ${
1009 state.pos - 1
1010 }`,
1011 );
1012}
1013
1014function parseDate(state: ParserState): BareItem {
1015 if (consume(state) !== "@") {

Callers 1

parseBareItemFunction · 0.85

Calls 1

consumeFunction · 0.85

Tested by

no test coverage detected