Ackee icon indicating copy to clipboard operation
Ackee copied to clipboard

Replace human-number with Intl.NumberFormat

Open Copilot opened this issue 3 months ago • 3 comments

Replaces the human-number dependency with native Intl.NumberFormat API using compact notation for number formatting with SI prefixes (K, M, B, T).

Changes

  • New utility: Created formatCompactNumber(num, maximumFractionDigits) in UI utils (src/ui/scripts/utils/)

    • Uses Intl.NumberFormat with notation: 'compact' and compactDisplay: 'short'
    • Configurable decimal precision via maximumFractionDigits parameter
  • Simplified formatters: Refactored formatNumber.js and formatFloat.js to delegate to the shared utility

  • Dependencies: Removed human-number from package.json

Example

// Before
import humanNumber from 'human-number'
const formatted = humanNumber(roundedNum, (num) => Number.parseFloat(num).toFixed(1))
const clean = formatted.replace('.0', '')

// After
import formatCompactNumber from './formatCompactNumber'
const formatted = formatCompactNumber(roundedNum, 1)

Output remains consistent: 1500 → "1.5K", 1000000 → "1M", 1500000000 → "1.5B"

> [!WARNING] > >

Original prompt

Replace human-number with Intl.RelativeTimeFormat. Create a reusable function when used multiple times. Add tests.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot avatar Nov 10 '25 07:11 Copilot

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
ackee Ready Ready Preview Comment Nov 10, 2025 11:36am

vercel[bot] avatar Nov 10 '25 07:11 vercel[bot]

@copilot Remove test/utils/formatCompactNumber.js and src/utils/formatCompactNumber.js

electerious avatar Nov 10 '25 11:11 electerious

@copilot Remove test/utils/formatCompactNumber.js and src/utils/formatCompactNumber.js

Removed both files in commit 62a5203. The UI utility in src/ui/scripts/utils/formatCompactNumber.js remains and is used by formatNumber.js and formatFloat.js.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot avatar Nov 10 '25 11:11 Copilot