go-get-folder-size

command module
v0.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 4 Imported by: 0

README

go-get-folder-size

go concurrently get folder size quickly, can run in nodejs


README 🦉

简体中文 | English


features


motivation

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。


Usage

npm

install
npm install go-get-folder-size
cli
# Binary go, fastest
npx go-get-folder-size
program
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
IPC

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

cli
go install github.com/markthree/go-get-folder-size
go-get-folder-size
program
# 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
}

loose

Sometimes we may encounter inaccessible files, and we can set loose to ignore them

cli

go-get-folder-size --loose

program

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

stack


License

Made with markthree

Published under MIT License.

Documentation

Overview

go-cli

Directories

Path Synopsis
js-wasm
js-wasm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL