# humanize

> Javascript string formatter for human readability

Latest version **0.0.9** (published 2013-09-19) · 0 weekly downloads

## Install

```sh
npm install humanize
pnpm add humanize
yarn add humanize
bun add humanize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2013-09-19 |
| First published | 2012-05-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 360 |
| Author | Tai-Jin Lee |
| Maintainers | taijin |
| Keywords | util, client, browser |

## Links

- npm: https://www.npmjs.com/package/humanize
- Repository: https://github.com/taijinlee/humanize
- Issues: https://github.com/taijinlee/humanize/issues
- npm.io page: https://npm.io/package/humanize

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.9 (latest) — 2013-09-19
- 0.0.8 — 2013-07-10
- 0.0.7 — 2013-04-21
- 0.0.6 — 2012-06-22
- 0.0.5 — 2012-06-12
- 0.0.4 — 2012-05-26
- 0.0.3 — 2012-05-26
- 0.0.2 — 2012-05-25
- 0.0.1 — 2012-05-24

## README

# humanize #

Javascript data formatter for human readability.

Idea, name, and initial code blatently stolen from [milanvrekic/JS-humanize](http://github.com/milanvrekic/JS-humanize)

Can be loaded via AMD or in node directly.

## Installation ##

    npm install humanize

## Usage: ##
```javascript
var humanize = require('humanize');
humanize.date('Y-m-d'); // 'yyyy-mm-dd'
humanize.filesize(1234567890); // '1.15 Gb'
```

## Functions available: ##

####humanize.noConflict()####
Give control of the "humanize" variable back to its previous owner. Returns a reference to the humanize object.

####humanize.time()####
Retrieves the current time in seconds

####humanize.date(format [, timestamp / JS Date Object = new Date()])####
This is a port of [php.js date](http://phpjs.org/functions/date:380) and behaves exactly like [PHP's date](http://php.net/manual/en/function.date.php)

####humanize.numberFormat(number [, decimals = 2, decPoint = '.', thousandsSep = ','])####
Format a number to have decimal significant decimal places, using decPoint as the decimal separator, and thousandsSep as thousands separater

####humanize.naturalDay(timestamp [, format = 'Y-m-d'])####
Returns 'today', 'tomorrow' or 'yesterday', as appropriate, otherwise format the date using the passed format with humanize.date()

####humanize.relativeTime(timestamp)####
Returns a relative time to the current time, seconds as the most granular up to years to the least granular.

####humanize.ordinal(integer)####
Converts a number into its [ordinal representation](http://en.wikipedia.org/wiki/Ordinal_number_\(linguistics\)).

####humanize.filesize(filesize [, kilo = 1024, decimals = 2, decPoint = '.', thousandsSep = ',']) ####
Converts a byte count to a human readable value using kilo as the basis, and numberFormat formatting

####humanize.linebreaks(string)####
Converts a string's newlines into properly formatted html ie. one new line -> br, two new lines -> p, entire thing wrapped in p

####humanize.nl2br(string)####
Converts a string's newlines into br's

####humanize.truncatechars(string, length)####
Truncates a string to length-1 and appends '…'. If string is shorter than length, then no-op

####humanize.truncatewords(string, numWords)####
Truncates a string to only include the first numWords words and appends '…'. If string has fewer words than newWords, then no-op

---
_Source: https://npm.io/package/humanize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
