# @timhall/fingerprint

> Fingerprint directories and files

Latest version **0.2.0** (published 2020-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @timhall/fingerprint
pnpm add @timhall/fingerprint
yarn add @timhall/fingerprint
bun add @timhall/fingerprint
```

Provides the command `fingerprint`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-07-08 |
| First published | 2020-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Hall |
| Maintainers | timhall |

## Links

- npm: https://www.npmjs.com/package/@timhall/fingerprint
- Repository: https://github.com/timhall/yarn-workspaces
- Homepage: https://github.com/timhall/yarn-workspaces#readme
- Issues: https://github.com/timhall/yarn-workspaces/issues
- npm.io page: https://npm.io/package/@timhall/fingerprint

## Dependencies (6)

- [ignore](https://npm.io/package/ignore.md) ^5.1.4
- [find-up](https://npm.io/package/find-up.md) ^4.1.0
- [multibase](https://npm.io/package/multibase.md) ^0.6.0
- [multihashes](https://npm.io/package/multihashes.md) ^0.4.15
- [@timhall/cli](https://npm.io/package/@timhall/cli.md) ^0.5.0
- [@timhall/dedent](https://npm.io/package/@timhall/dedent.md) ^0.8.1

## Recent versions

- 0.2.0 (latest) — 2020-07-08
- 0.1.6 — 2020-04-05
- 0.1.3 — 2020-04-05
- 0.1.1 — 2020-04-03
- 0.1.0 — 2020-04-03

## README

# @timhall/fingerprint

Calculate a hash fingerprint for directories and files.

```js
const { fingerprintDir } = require('@timhall/fingerprint');

// Calculate a fingerprint of the current working directory using
// - filter = active .gitignore files
// - algorithm = sha1
// - encoding = base64
const a = await fingerprintDir(process.cwd());
```

```js
const { fingerprintDir, fingerprintFile } = require('@timhall/fingerprint');
const { join } = require('path');

const b = await fingerprintDir(process.cwd(), {
  algorithm: 'sha256',
  encoding: 'hex',
  filter: absolutePath => /^\./.test(absolutePath)
});

const c = await fingerprintFile(join(__dirname, 'file.txt'));
```

## fingerprintDir(dir: string, [options]): Promise<string>

Options:

- [algorithm = 'sha1'] - Hash algorithm, `'sha1'`, `'sha256'`, or `'sha512'`
- [encoding = 'base64'] - Encoding, `'base64'` or `'hex'`
- [filter = (by gitignore)] - Filter function, given absolute path and return `true` to include file or `false` to exclude

## fingerprintFile(file: string, [options]): Promise<string>

Options:

- [algorithm = 'sha1'] - Hash algorithm, `'sha1'`, `'sha256'`, or `'sha512'`
- [encoding = 'base64'] - Encoding, `'base64'` or `'hex'`

---
_Source: https://npm.io/package/@timhall/fingerprint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
