Registry / serialization / humanize-plus

humanize-plus

JSON →
library1.8.2jsnpmunverified

Humanize Plus is a utility library designed to make data presented on the web more digestible and 'humane'. It provides a collection of functions for formatting numbers, file sizes, and time-related values into human-readable strings. The current stable version is 1.8.2, with recent releases primarily focusing on minor updates and deprecating older methods in preparation for a potential v2.0. The library's release cadence appears to be slow, with several months or years between significant updates. Key differentiators include its broad range of number and time formatting utilities, such as `compactInteger` for abbreviating large numbers, `fileSize` for converting byte counts, `intComma` for comma-separating integers, `ordinal` for adding suffixes like "st" or "nd", and `pace` for interpreting rates over time. It supports both Node.js (via CommonJS) and browser environments (via a global `Humanize` object).

npm install humanize-plus
INSTALL
IMPORT
SIG · HUMANIZE-PLUS
H
humanize-plus
serializationjavascriptv1.8.2
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.

Humanize
const Humanize = require('humanize-plus');
import Humanize from 'humanize-plus';
For Node.js environments, humanize-plus is a CommonJS module that exports a single `Humanize` object containing all utility methods. Named imports (`import { methodName } from 'pkg'`) are not supported.
Humanize
// <script src="humanize.min.js"></script> // ... then access via global `Humanize` object
require('humanize-plus'); // Not for browser global scope
In a browser environment, after including the script, all utility methods are available on the global `Humanize` object.
compactInteger
const Humanize = require('humanize-plus'); Humanize.compactInteger(123456, 1);
import { compactInteger } from 'humanize-plus';
Individual methods must be accessed from the main `Humanize` object after importing the entire module. The package does not offer named exports for individual functions.

Demonstrates importing `humanize-plus` in Node.js and using several core formatting functions like `compactInteger`, `fileSize`, `intComma`, and `ordinal`.

const Humanize = require('humanize-plus'); console.log('Original number:', 123456789); console.log('Compact integer (1 decimal place):', Humanize.compactInteger(123456789, 1)); // Expected: "123.5M" console.log('Original file size:', 1024 * 2000); console.log('Human-readable file size:', Humanize.fileSize(1024 * 2000)); // Expected: "1.95 Mb" console.log('Formatting with commas:', Humanize.intComma(987654321)); // Expected: "987,654,321" console.log('Ordinal for 22:', Humanize.ordinal(22)); // Expected: "22nd"
Debug
Known issues
deprecatedThe `intcomma` method is deprecated. Use `Humanize.intComma` (camelCase) instead.
fix
Replace `Humanize.intcomma(...)` with `Humanize.intComma(...)`.
affects: >=1.4.2
deprecatedThe `intword` method is deprecated. It is now a thin wrapper around `Humanize.compactInteger` and will be removed in the next major version (v2).
fix
Migrate to using `Humanize.compactInteger(...)` directly for future compatibility.
affects: >=1.4.2
deprecatedThe `truncatenumber` method is deprecated. Use `Humanize.boundedNumber` instead.
fix
Replace `Humanize.truncatenumber(...)` with `Humanize.boundedNumber(...)`.
affects: >=1.4.2
deprecatedThe `filesize` method is deprecated. Use `Humanize.fileSize` (camelCase) instead.
fix
Replace `Humanize.filesize(...)` with `Humanize.fileSize(...)`.
affects: >=1.4.2
breakingSupport for Node.js v0.6 was dropped in version 1.5.0. Ensure your Node.js environment is v0.8.0 or newer.
fix
Upgrade your Node.js runtime to version 0.8.0 or higher.
affects: >=1.5.0
breakingSeveral methods (intcomma, intword, truncatenumber, filesize) have been marked as deprecated since v1.4.2 and are explicitly stated to 'not be present in the next major version' (v2). Relying on these will cause breakage.
fix
Update all calls to deprecated methods to their recommended replacements (e.g., `intComma`, `compactInteger`, `boundedNumber`, `fileSize`) before upgrading to version 2.x.
affects: >=1.4.2
Errors
Common errors & fixes
TypeError: Humanize.intcomma is not a function
Attempting to use the deprecated lowercase method name `intcomma` instead of `intComma`.
fix
Change the method call from `Humanize.intcomma(...)` to `Humanize.intComma(...)`.
ReferenceError: Humanize is not defined
The `humanize-plus` script has not been loaded in the browser, or it's being accessed outside its intended scope.
fix
Ensure `<script src="humanize.min.js"></script>` is correctly included in your HTML before attempting to use the `Humanize` global object.
ReferenceError: require is not defined
Attempting to use Node.js CommonJS `require()` in a browser environment without a module bundler.
fix
For browser usage, include the library via a `<script>` tag and access the global `Humanize` object. If using a bundler (like Webpack or Rollup), ensure it's configured to handle CommonJS modules.
SyntaxError: The requested module 'humanize-plus' does not provide an export named 'compactInteger'
Attempting to use ES module named imports for `humanize-plus`, which is a CommonJS module that exports a single object.
fix
Use CommonJS `require` syntax: `const Humanize = require('humanize-plus');` and then access methods like `Humanize.compactInteger(...)`.
Upgrade
Version history
1.8.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources