Socket
Socket
Sign inDemoInstall

pretty-bytes

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 6.1.0

20

index.d.ts

@@ -59,2 +59,3 @@ export interface Options {

@example
```

@@ -80,2 +81,3 @@ import prettyBytes from 'pretty-bytes';

@example
```

@@ -93,2 +95,20 @@ import prettyBytes from 'pretty-bytes';

readonly maximumFractionDigits?: number;
/**
Put a space between the number and unit.
@default true
@example
```
import prettyBytes from 'pretty-bytes';
prettyBytes(1920, {space: false});
//=> '1.9kB'
prettyBytes(1920);
//=> '1.92 kB'
```
*/
readonly space?: boolean;
}

@@ -95,0 +115,0 @@

9

index.js

@@ -74,2 +74,3 @@ const BYTE_UNITS = [

binary: false,
space: true,
...options,

@@ -82,4 +83,6 @@ };

const separator = options.space ? ' ' : '';
if (options.signed && number === 0) {
return ` 0 ${UNITS[0]}`;
return ` 0${separator}${UNITS[0]}`;
}

@@ -106,3 +109,3 @@

const numberString = toLocaleString(number, options.locale, localeOptions);
return prefix + numberString + ' ' + UNITS[0];
return prefix + numberString + separator + UNITS[0];
}

@@ -121,3 +124,3 @@

return prefix + numberString + ' ' + unit;
return prefix + numberString + separator + unit;
}
{
"name": "pretty-bytes",
"version": "6.0.0",
"version": "6.1.0",
"description": "Convert bytes to a human readable string: 1337 → 1.34 kB",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -126,2 +126,19 @@ # pretty-bytes

##### space
Type: `boolean`\
Default: `true`
Put a space between the number and unit.
```js
import prettyBytes from 'pretty-bytes';
prettyBytes(1920, {space: false});
//=> '1.9kB'
prettyBytes(1920);
//=> '1.92 kB'
```
## Related

@@ -128,0 +145,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc