-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aslan Baryshnikov
committed
Apr 25, 2022
1 parent
bf08fbd
commit a7aeaea
Showing
8 changed files
with
9,166 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"env": { | ||
"commonjs": true, | ||
"es2021": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"airbnb-base" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
const convertBytes = (bytes) => { | ||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | ||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | ||
|
||
if (bytes === 0) | ||
return 'n/a'; | ||
if (bytes === 0) return 'n/a'; | ||
|
||
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | ||
const i = parseInt(String(Math.floor(Math.log(bytes) / Math.log(1024))), 10); | ||
|
||
if (i === 0) | ||
return bytes + ' ' + sizes[i]; | ||
if (i === 0) return `${bytes} ${sizes[i]}`; | ||
|
||
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | ||
return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`; | ||
}; | ||
|
||
module.exports = convertBytes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const getAllDirectories = (sourcePath) => { | ||
const directories = [sourcePath]; | ||
|
||
function throughDirectory(directory) { | ||
fs.readdirSync(directory).forEach((item) => { | ||
const absolute = path.join(directory, item); | ||
if (!fs.statSync(absolute).isDirectory()) return; | ||
directories.push(absolute); | ||
throughDirectory(absolute); | ||
}); | ||
} | ||
throughDirectory(sourcePath); | ||
|
||
return directories; | ||
}; | ||
|
||
module.exports = getAllDirectories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.