bytes-formatter 21.6.14 → 21.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/index.js +2 -2
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Bytes Formatter [](https://twitter.com/intent/tweet?text=Bytes%20formatter%20module.&url=https://github.com/vpodk/bytes-formatter&via=GitHub&hashtags=JavaScript,ECMAScript,ES6)
|
|
2
2
|
|
|
3
|
-
[](https://github.com/vpodk/bytes-formatter/actions/workflows/npm-publish.yml) [](https://www.apache.org/licenses/LICENSE-2.0.html) [](https://npmjs.org/package/bytes-formatter) [](https://npmjs.org/package/bytes-formatter)
|
|
3
|
+
[](https://github.com/vpodk/bytes-formatter/actions/workflows/npm-publish.yml) [](https://www.apache.org/licenses/LICENSE-2.0.html) [](https://npmjs.org/package/bytes-formatter) [](https://npmjs.org/package/bytes-formatter) 
|
|
4
4
|
|
|
5
|
-
Bytes formatter module.
|
|
5
|
+
Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
@@ -20,5 +20,11 @@ import { formatBytes } from "bytes-formatter";
|
|
|
20
20
|
* @param {number} bytes The bytes to be formatted.
|
|
21
21
|
* @return {string} The formatted bytes as string.
|
|
22
22
|
*/
|
|
23
|
-
console.log(formatBytes(
|
|
23
|
+
console.log(formatBytes(1000)); // "1000 bytes"
|
|
24
|
+
console.log(formatBytes(1024)); // "1.00 KB"
|
|
25
|
+
console.log(formatBytes(1000000)); // "976.56 KB"
|
|
26
|
+
console.log(formatBytes(2000000)); // "1.91 MB"
|
|
27
|
+
console.log(formatBytes(2000000000)); // "1.86 GB"
|
|
28
|
+
console.log(formatBytes(2000000000000)); // "1.82 TB"
|
|
29
|
+
console.log(formatBytes(Number.MAX_SAFE_INTEGER)); // "8.00 PB"
|
|
24
30
|
```
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Bytes formatter module
|
|
3
3
|
*
|
|
4
|
-
* @see https://google.github.io/styleguide/
|
|
5
|
-
* @see https://
|
|
4
|
+
* @see https://google.github.io/styleguide/jsguide.html
|
|
5
|
+
* @see https://google.github.io/styleguide/tsguide.html
|
|
6
6
|
* @module bytes-formatter
|
|
7
7
|
*/
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bytes-formatter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "21.6.
|
|
5
|
-
"description": "Bytes formatter module",
|
|
6
|
-
"homepage": "https://
|
|
4
|
+
"version": "21.6.16",
|
|
5
|
+
"description": "Bytes formatter module provides a function to format byte values into human-readable strings with appropriate units (bytes, KB, MB, GB, TB, PB).",
|
|
6
|
+
"homepage": "https://vpodk.com/bytes-formatter/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/vpodk/bytes-formatter.git"
|
|
9
9
|
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/vpodk/bytes-formatter/issues"
|
|
12
|
+
},
|
|
13
|
+
"funding": {
|
|
14
|
+
"url": "https://github.com/sponsors/vpodk"
|
|
15
|
+
},
|
|
10
16
|
"license": "Apache-2.0",
|
|
11
17
|
"main": "./index.js",
|
|
12
18
|
"exports": "./index.js",
|
|
@@ -14,9 +20,6 @@
|
|
|
14
20
|
"scripts": {
|
|
15
21
|
"test": "node ./index.tests.js"
|
|
16
22
|
},
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/vpodk/bytes-formatter/issues"
|
|
19
|
-
},
|
|
20
23
|
"author": {
|
|
21
24
|
"name": "Valentin Podkamennyi",
|
|
22
25
|
"email": "vpodk@users.noreply.github.com",
|