PageSourceSearch

https://flyai-mine.fly.dev/compute/mine/web/format.js

js flyai-mine.fly.dev collected 2026-10-03 08:13:50 UTC 770 bytes, 17 lines download raw bytes

1/**
2 * Token amounts for people to read: exact below 10,000 ("2,000", "12.5"), compact above it ("13.7K", "2.5M",
3 * "1.2B"), with at most three significant digits. Display only: anything sent or signed uses the exact value.
4 */
5export function compact(n        )         {
6  if (!Number.isFinite(n)) return "–";
7  const abs = Math.abs(n);
8  if (abs < 10_000) return n.toLocaleString("en-US", { maximumFractionDigits: abs < 1 ? 4 : 2 });
9  for (const [size, unit] of [[1e12, "T"], [1e9, "B"], [1e6, "M"], [1e3, "K"]]         ) {
10    if (abs >= size) {
11      const x = n / size;
12      const digits = Math.abs(x) < 10 ? 2 : Math.abs(x) < 100 ? 1 : 0;
13      return `${x.toLocaleString("en-US", { maximumFractionDigits: digits })}${unit}`;
14    }
15  }
16  return String(n);
17}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.