sindresorhus

pretty-bytes

Convert bytes to a human readable string: 1337 → 1.34 kB

by sindresorhus

JavaScript

JavaScript99.3%
TypeScript0.7%

Commit activity

Last 12 weeks · 8 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template
imshunsuke

and currently force even when is (the default). This makes the output depend on the system locale and can add localized decimal or grouping separators, contrary to the documented behavior. For example, with a German system locale: Large values also gain grouping separators (, , and so on). This uses deterministic number formatting with grouping disabled only when fractional-digit options require formatting without localization. Explicit , string, and locale-array behavior remains unchanged. Regression coverage includes the default and explicit paths for both and . Validation: on Node.js 22.23.2.

imshunsuke · 1mo ago
spokodev

Rounding to 3 significant digits happens after the unit is selected, so a value just below the next boundary rounds up to the base while the unit stays put — producing an out-of-range label: and are never valid outputs — the whole point of unit selection is that the mantissa stays below the base. Fix Extract the rounding into , which promotes to the next unit when the rounded value reaches the base and a larger unit exists: The guard keeps the top unit (YB/YiB) from over-advancing. This still rounds to 3 significant digits (advancing the unit is itself 3 sig figs — ), and the / locale path is untouched. Extracting the helper also keeps within the complexity limit. Tests Boundary cases for SI, binary, and bits added to ; they emit the out-of-range unit before the change and pass after. Full suite green.

spokodev · 1mo ago
xxjaemin68

Small chore: adds a PR template. New PRs will get a lightweight checklist for description, type-of-change, and a couple of contributor checkboxes. Doesn't force anything — GitHub just pre-fills the description field.

xxjaemin68 · 2mo ago
Structured data for AI agents

Repository: sindresorhus/pretty-bytes. Description: Convert bytes to a human readable string: 1337 → 1.34 kB Stars: 1318, Forks: 95. Primary language: JavaScript. Languages: JavaScript (99.3%), TypeScript (0.7%). License: MIT. Latest release: v7.2.0 (3w ago). Open PRs: 0, open issues: 0. Last activity: 3w ago. Community health: 85%. Top contributors: sindresorhus, nmoinvaz, kevva, NMinhNguyen, Turbo87, siddhant-nair, meisterlampe, jakecastelli, dawsbot, yciabaud and others.