00h
v1.0.0
Published
Format a number as a three-digit, zero-padded string (fixed-width codes).
Maintainers
Readme
006
Format a number as a three-digit, zero-padded string — the shape used by many numeric codes (ISO-style IDs, ticket numbers, fixed-width export formats).
const code3 = require('006');
code3(6); // '006'
code3('42'); // '042'
code3(12345); // '12345' (longer input returned as-is)Zero dependencies. TypeScript types included.
API
code3(value)
| Argument | Type | Description |
|---|---|---|
| value | number \| string | Value to format. Non-numeric input is treated as 0; fractions are truncated; the sign is dropped. |
Returns a string padded to at least 3 digits.
License
MIT
