Registry / serialization / wnumb
library1.2.0jsnpmunverified

wNumb is a lightweight JavaScript utility designed specifically for number and money formatting. It enables developers to control aspects such as decimal places, thousands separators, and the addition of prefixes or suffixes to numerical values, facilitating clear and readable data presentation. The current stable version is 1.2.0, released in October 2019. The project appears to have an irregular release cadence, with no updates since 2019, suggesting it is currently in a maintenance phase rather than active development. Its core value lies in offering a focused, minimal API for common formatting needs, differentiating itself from more comprehensive internationalization libraries by prioritizing simplicity and a small footprint.

npm install wnumb
INSTALL
IMPORT
SIG · WNUMB
W
wnumb
serializationjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wNumb
import wNumb from 'wnumb';
import { wNumb } from 'wnumb';
wNumb is typically consumed as a default export when using modern bundlers or CommonJS environments. It is not a named export.
wNumb (CommonJS)
const wNumb = require('wnumb');
For Node.js or older environments using CommonJS, wNumb is imported as a module.
wNumb (Global)
const formatter = wNumb({...}); // Assumes wNumb script tag is present
When included via a <script> tag in a browser, wNumb is exposed globally as the 'wNumb' function.

Demonstrates how to create and use wNumb formatters for currency, percentages, and custom numeric transformations, including encoding and decoding values.

import wNumb from 'wnumb'; // For module environments like Node.js or bundlers // If using directly in browser via script tag, 'wNumb' is global. // Create a currency formatter for USD const usdFormatter = wNumb({ decimals: 2, // Number of decimals (e.g., 2 for $XX.XX) mark: '.', // Decimal separator thousand: ',', // Thousands separator prefix: '$ ', suffix: ' USD' }); console.log(usdFormatter.to(12345.678)); // Expected output: "$ 12,345.68 USD" console.log(usdFormatter.from('$ 5,432.10 USD')); // Expected output: 5432.1 // Create a percentage formatter const percentFormatter = wNumb({ decimals: 0, suffix: '%' }); console.log(percentFormatter.to(0.75)); // Expected output: "75%" console.log(percentFormatter.from('99%')); // Expected output: 0.99 // A simple number formatter with specific rounding const numberFormatter = wNumb({ decimals: 3, encoder: value => value * 2, // Example: custom encode function decoder: value => value / 2 // Example: custom decode function }); console.log(numberFormatter.to(10.1234)); // Expected output: "20.247" (10.1234 * 2 = 20.2468, rounded to 3 decimals)
Debug
Known issues
breakingThe `postfix` option was renamed to `suffix` in version 1.1.0. While `postfix` is remapped internally for backward compatibility, relying on the old name is deprecated and may lead to unexpected behavior or removal in future updates.
fix
Update your formatter configurations to use `suffix` instead of `postfix`.
affects: >=1.1.0
gotchaWhen formatting small negative numbers with `decimals` set to 0, older versions (prior to 1.0.2) could display '-0' instead of '0'.
fix
Upgrade to wNumb version 1.0.2 or newer to resolve this display issue.
affects: <1.0.2
gotchaEarly versions (prior to 1.0.1) had issues with decimal handling, potentially leading to incorrect formatting or parsing of values with fractional components.
fix
Upgrade to wNumb version 1.0.1 or newer to ensure correct decimal processing.
affects: <1.0.1
Errors
Common errors & fixes
Formatter outputs '-0' for negative numbers with `decimals: 0`
You are using an older version of wNumb (prior to 1.0.2) which had a bug in rounding very small negative numbers.
fix
Upgrade your wNumb package to version 1.0.2 or higher.
Unexpected behavior or incorrect parsing when handling decimal values.
Your wNumb version is older than 1.0.1, which contained a bug related to decimal processing.
fix
Upgrade your wNumb package to version 1.0.1 or higher.
The `postfix` option is ignored or does not apply the desired text.
In version 1.1.0, the `postfix` option was renamed to `suffix`. While an internal remapping exists, direct use of `suffix` is recommended.
fix
Change your formatter configuration from `postfix: 'TEXT'` to `suffix: 'TEXT'`.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
wnumb — npm install wnumb · libregistry