{"version":3,"file":"_httpHeaderReadBigint.mjs","names":[],"sources":["../../src/internal/_httpHeaderReadBigint.ts"],"sourcesContent":["/**\n * Read one header value as a bigint.\n *\n * A blank value is absent, and other text is converted when it parses and kept\n * as text otherwise.\n *\n * @evidence contracts/common.md#principled-implementation A blank header, or a blank element, is absent because `BigInt(\"\")` would read as zero; other text is converted when it parses and left as text when it does not.\n * @evidence contracts/common.md#clear-and-simple-design One conditional and two private helpers.\n * @evidence contracts/common.md#prohibited-implementation-shortcuts The blank rule follows the cited issue.\n * @evidence contracts/common.md#meaningful-documentation A comment states the cases.\n */\nexport const _httpHeaderReadBigint = (value: string | undefined) =>\n  // A blank header, or a blank element of a header list, is absent: `BigInt(\"\")`\n  // is 0n, which let validators accept an empty header as a real zero (#2448).\n  value !== undefined && isBlank(value) === false ? toBigint(value) : undefined;\n\nconst isBlank = (value: string): boolean =>\n  typeof value === \"string\" && value.trim().length === 0;\n\nconst toBigint = (str: string): bigint | string => {\n  try {\n    return BigInt(str);\n  } catch {\n    return str;\n  }\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,yBAAyB,UAGpC,UAAU,KAAA,KAAa,QAAQ,KAAK,MAAM,QAAQ,SAAS,KAAK,IAAI,KAAA;AAEtE,MAAM,WAAW,UACf,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,WAAW;AAEvD,MAAM,YAAY,QAAiC;CACjD,IAAI;EACF,OAAO,OAAO,GAAG;CACnB,QAAQ;EACN,OAAO;CACT;AACF"}