Skip to content

Commit 5b033f7

Browse files
authored
docs: update readme example (#11)
* docs: update readme example Fixes #9 * chore: update formatBytes
1 parent bcd23ea commit 5b033f7

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
steps:
2929
- name: Checkout repository
3030
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
3133
- name: Create Diff
3234
uses: e18e/action-dependency-diff@main
3335
```

main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24198,8 +24198,8 @@ async function calculateTotalDependencySizeIncrease(newVersions) {
2419824198
// src/main.ts
2419924199
function formatBytes(bytes) {
2420024200
if (bytes === 0) return "0 B";
24201-
const k = 1024;
24202-
const sizes = ["B", "KB", "MB", "GB"];
24201+
const k = 1e3;
24202+
const sizes = ["B", "kB", "MB", "GB"];
2420324203
const i = Math.floor(Math.log(bytes) / Math.log(k));
2420424204
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
2420524205
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {calculateTotalDependencySizeIncrease} from './npm.js';
77

88
function formatBytes(bytes: number): string {
99
if (bytes === 0) return '0 B';
10-
const k = 1024;
11-
const sizes = ['B', 'KB', 'MB', 'GB'];
10+
const k = 1000;
11+
const sizes = ['B', 'kB', 'MB', 'GB'];
1212
const i = Math.floor(Math.log(bytes) / Math.log(k));
1313
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
1414
}

0 commit comments

Comments
 (0)