Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

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.

@vercel
Copy link

vercel bot commented Nov 10, 2025

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

…rFormat

Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace human-number with Intl.RelativeTimeFormat Replace human-number with Intl.NumberFormat Nov 10, 2025
Copilot AI requested a review from electerious November 10, 2025 07:16
@electerious
Copy link
Owner

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

Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 10, 2025

@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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants