{"version":3,"file":"_httpQueryReadNumber.mjs","names":[],"sources":["../../src/internal/_httpQueryReadNumber.ts"],"sourcesContent":["/**\n * Read one query value as a number.\n *\n * Blank text is absent, `null` is null and other text is converted when it is a\n * number and kept as text otherwise.\n *\n * @evidence contracts/common.md#principled-implementation Blank or missing text is absent because `Number(\" \")` would read as zero, the text `null` is null and other text is converted when it is a number and kept as text otherwise.\n * @evidence contracts/common.md#clear-and-simple-design One conditional and a private converter.\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 _httpQueryReadNumber = (\n  str: string | null,\n): number | null | undefined =>\n  // Blank text is absent, as the empty string always was: `Number(\" \")` is 0,\n  // which would read a whitespace value as a real zero (#2448).\n  typeof str === \"string\" && str.trim().length !== 0\n    ? str === \"null\"\n      ? null\n      : (toNumber(str) as any)\n    : undefined;\n\nconst toNumber = (str: string): number | string => {\n  const value: number = Number(str);\n  return isNaN(value) ? str : value;\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,wBACX,QAIA,OAAO,QAAQ,YAAY,IAAI,KAAK,CAAC,CAAC,WAAW,IAC7C,QAAQ,SACN,OACC,SAAS,GAAG,IACf,KAAA;AAEN,MAAM,YAAY,QAAiC;CACjD,MAAM,QAAgB,OAAO,GAAG;CAChC,OAAO,MAAM,KAAK,IAAI,MAAM;AAC9B"}