@paqjs/core
v1.5.0
Published
Hash file or directory recursively.
Downloads
186
Maintainers
Readme
paqjs
Hash file or directory recursively.
Node.js bindings to the Rust paq library.
Powered by blake3 cryptographic hashing algorithm.
Performance
The Go programming language repository was used as a test data source (157 MB / 14,490 files).
| Tool | Version | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------- | :------ | :------------------------ | ------------: | -------: | -------: | -----------: |
| paq | latest | paq ./go | 77.7 ± 0.6 | 77.1 | 80.2 | 1.00 |
| b3sum | 1.5.1 | find ./go ... b3sum | 327.3 ± 3.6 | 320.2 | 332.3 | 4.21 ± 0.05 |
| dirhash | 0.5.0 | dirhash -a sha256 ./go | 576.1 ± 2.9 | 570.8 | 580.3 | 7.41 ± 0.06 |
| GNU sha2 | 9.7 | find ./go ... sha256sum | 725.2 ± 43.5 | 692.2 | 813.2 | 9.33 ± 0.56 |
| folder-hash | 4.1.1 | folder-hash ./go | 1906.0 ± 78.0 | 1810.0 | 2029.0 | 24.53 ± 1.02 |
See paq benchmarks documentation for more details.
Installation
Install From NPM
npm install @paqjs/coreInstall From Repository (Unstable)
Not recommended due to instability of main branch in-between tagged releases.
- Clone this repository.
- Run
npm installfrom repository root. - Run
npm run buildto build.nodebinary.
Usage
Typescript
import { hashSource } from '@paqjs/core';
const source: string = "/path/to/source";
const ignore_hidden: boolean = true; // .dir or .file
const source_hash: string = hashSource(
source,
ignore_hidden,
);
console.log(source_hash);hashSource returns a hexadecimal hash string. File system failures throw a
JavaScript Error with the underlying paq error message.
Javascript
const { hashSource } = require('@paqjs/core');
const source = "/path/to/source";
const ignore_hidden = true; // .dir or .file
const source_hash = hashSource(
source,
ignore_hidden,
);
console.log(source_hash);Visit the paq homepage for more details.
