{"version":3,"file":"absent.cjs","names":[],"sources":["../../src/utils/absent.ts"],"sourcesContent":["/**\n * What every formatter prints when it has nothing to print.\n *\n * An em dash rather than an empty string, because in a table those are two\n * different claims: a blank cell reads as \"this column does not apply here\",\n * while `—` reads as \"this value is missing\". `formatDurationMs` in `/perf` has\n * answered this way since it shipped, and `formatPercent` joined it in 0.65.0;\n * this constant is what stops the third answer from appearing.\n */\nexport const ABSENT_TEXT = \"—\";\n\n/** The text a formatter falls back to when the value cannot be rendered. */\nexport interface FormatFallbackOptions {\n    /**\n     * Text for a value that is absent (`null`/`undefined`) or unrepresentable\n     * (`NaN`, `Infinity`). Defaults to {@link ABSENT_TEXT}.\n     *\n     * The formatters that feed an `<input>` default to `\"\"` instead, because an\n     * input reads an empty string as \"no value\" and would render an em dash as\n     * content the user has to delete.\n     */\n    fallback?: string;\n}\n\n/**\n * Whether a value is absent, i.e. has nothing to format.\n *\n * `null` and `undefined` only. A present-but-unparseable value is a different\n * state, and the formatters keep it distinguishable: an ISO string that is not a\n * date still answers `\"\"`, which is what tells \"nobody filled this in\" apart\n * from \"what they filled in is broken\" while reading a log.\n *\n * @param value - Anything a formatter was handed.\n * @returns Whether the formatter should answer with the fallback.\n */\nexport function isAbsent(value: unknown): value is null | undefined {\n    return value === null || value === undefined;\n}\n\n/**\n * Resolve the fallback text for a formatter call.\n *\n * @param options - The caller's options, if any.\n * @param defaultText - What this formatter uses when the caller said nothing.\n * @returns The text to render in place of the value.\n */\nexport function fallbackText(\n    options: FormatFallbackOptions | undefined,\n    defaultText: string = ABSENT_TEXT,\n): string {\n    return options?.fallback ?? defaultText;\n}\n"],"mappings":"AASA,IAAa,EAAc,IA0B3B,SAAgB,EAAS,EAA2C,CAChE,OAAO,GAAU,IACrB,CASA,SAAgB,EACZ,EACA,EAAA,IACM,CACN,OAAO,GAAS,UAAY,CAChC"}