fast-dir-size
v1.3.0
Published
Calculates the total size of a folder and its subfolders.
Downloads
322
Maintainers
Readme
fast-dir-size
Calculates the total size of a folder and its subfolders.
Usage
Install with npm
npm i fast-dir-size
// load using import
import { getDirSize, getDirSizeSync } from 'fast-dir-size'
// or using commonjs
const { getDirSize, getDirSizeSync } = require('fast-dir-size')
const os = require('os');
const { join } = require('path');
const path = join(os.homedir(), 'Downloads');
// Example using asynchronous function
getDirSize(path)
.then((size) => console.log(`Size: ${size} bytes`)); // Output: Size: 338160322 bytes
// Example using synchronous function
const size = getDirSizeSync(path);
console.log(`Size: ${size} bytes`); // Output: Size: 338160322 bytes