简体中文 | English
- 🐉 ipc go
- 🦕 binary go
- 🦖 native node
- 🐊 wasm go
I want to know the folder size quickly, but the nodejs implementation of
get-folder-size is slow, so
using go implements a recursive get folder size that runs in nodejs and is
7 ~ 20
times faster than the node native solution under normal circumstances。
npm install go-get-folder-size
# Binary go, fastest
npx go-get-folder-size
import {
getFolderSize,
getFolderSizeBin,
getFolderSizeWasm,
} from "go-get-folder-size";
const base = "./"; // The directory path you want to get
await getFolderSizeBin(base); // Binary go, fastest
await getFolderSize(base); // native node
await getFolderSizeWasm(base); // Wasm go,slowest
Suitable for multi-path
import { createGetFolderSizeBinIpc } from "go-get-folder-size";
const { getFolderSizeWithIpc, close } = createGetFolderSizeBinIpc();
Promise.all([
getFolderSizeWithIpc("./"),
getFolderSizeWithIpc("../"),
])
.then((vs) => console.log(vs))
.finally(close); // Manual close is required
go install github.com/markthree/go-get-folder-size
go-get-folder-size
# Super invincible fast
go get github.com/markthree/go-get-folder-size
package main
import (
getFolderSize "github.com/markthree/go-get-folder-size/src"
)
func main() {
size, err := getFolderSize.Invoke("./") // Concurrent running, invincible fast
size2 := getFolderSize.LooseInvoke("./") // Sometimes we may encounter inaccessible files, and we can set 'loose' to ignore them
}
Sometimes we may encounter inaccessible files, and we can set loose
to ignore
them
go-get-folder-size --loose
import {
getFolderSize,
getFolderSizeBin,
getFolderSizeWasm,
} from "go-get-folder-size";
const base = "./"; // The directory path you want to get
const pretty = false; // Human readable way
const loose = true;
await getFolderSizeBin(base, pretty, { loose }); // Binary go, fastest
await getFolderSize(base, pretty, { loose }); // native node
await getFolderSizeWasm(base, pretty, { loose }); // Wasm go,slowest
Made with markthree
Published under MIT License.