pretty-bytes
Advanced tools
Comparing version 5.4.1 to 5.5.0
@@ -14,2 +14,3 @@ declare namespace prettyBytes { | ||
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …) | ||
- If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …) | ||
@@ -20,3 +21,3 @@ __Note:__ Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime. | ||
*/ | ||
readonly locale?: boolean | string; | ||
readonly locale?: boolean | string | readonly string[]; | ||
@@ -28,2 +29,3 @@ /** | ||
@example | ||
``` | ||
@@ -43,2 +45,3 @@ import prettyBytes = require('pretty-bytes'); | ||
@example | ||
``` | ||
@@ -45,0 +48,0 @@ import prettyBytes = require('pretty-bytes'); |
@@ -59,3 +59,3 @@ 'use strict'; | ||
let result = number; | ||
if (typeof locale === 'string') { | ||
if (typeof locale === 'string' || Array.isArray(locale)) { | ||
result = number.toLocaleString(locale); | ||
@@ -75,2 +75,3 @@ } else if (locale === true) { | ||
options = Object.assign({bits: false, binary: false}, options); | ||
const UNITS = options.bits ? | ||
@@ -81,3 +82,3 @@ (options.binary ? BIBIT_UNITS : BIT_UNITS) : | ||
if (options.signed && number === 0) { | ||
return ' 0 ' + UNITS[0]; | ||
return ` 0 ${UNITS[0]}`; | ||
} | ||
@@ -84,0 +85,0 @@ |
{ | ||
"name": "pretty-bytes", | ||
"version": "5.4.1", | ||
"version": "5.5.0", | ||
"description": "Convert bytes to a human readable string: 1337 → 1.34 kB", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -1,2 +0,2 @@ | ||
# pretty-bytes [![Build Status](https://travis-ci.com/sindresorhus/pretty-bytes.svg?branch=master)](https://travis-ci.com/github/sindresorhus/pretty-bytes) | ||
# pretty-bytes | ||
@@ -84,2 +84,3 @@ > Convert bytes to a human readable string: `1337` → `1.34 kB` | ||
- If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …) | ||
- If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …) | ||
@@ -86,0 +87,0 @@ **Note:** Localization should generally work in browsers. Node.js needs to be [built](https://github.com/nodejs/node/wiki/Intl) with `full-icu` or `system-icu`. Alternatively, the [`full-icu`](https://github.com/unicode-org/full-icu-npm) module can be used to provide support at runtime. [Node.js 13](https://nodejs.org/en/blog/release/v13.0.0/) and later ships with ICU by default. |
9234
153
92