useful-pi-extensions 1.10.2 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "useful-pi-extensions",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "A small collection of pi extensions, installed with one command — a labelled status line with context pressure, cache, cost, effort, TTFT and tokens/sec.",
5
5
  "keywords": [
6
6
  "bun",
@@ -332,9 +332,14 @@ export function withCachedRates(
332
332
  *
333
333
  * All of them, not just one: a converted amount lands on `¥17.80` often enough that a single
334
334
  * trailing zero would show up as `¥17.8` beside `¥2.71` and read as a different precision.
335
+ *
336
+ * A nonzero amount that rounds down to zero renders as a bounded floor, `<$0.01`, because `$0`
337
+ * claims nothing was spent — the one thing a billing figure must never say.
335
338
  */
336
339
  export function formatCost(cost: number, currency: Currency = USD): string {
337
- return `${currency.symbol}${(cost * currency.perUsd).toFixed(2).replace(/\.?0+$/, '')}`
340
+ const amount = cost * currency.perUsd
341
+ if (cost > 0 && Number(amount.toFixed(2)) === 0) return `<${currency.symbol}0.01`
342
+ return `${currency.symbol}${amount.toFixed(2).replace(/\.?0+$/, '')}`
338
343
  }
339
344
 
340
345
  /**