@timhall/fingerprint
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@timhall/fingerprint

Calculate a hash fingerprint for directories and files.

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());
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

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

Options:

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

Readme

Keywords

none

Package Sidebar

Install

npm i @timhall/fingerprint

Weekly Downloads

7

Version

0.2.0

License

MIT

Unpacked Size

11.7 kB

Total Files

14

Last publish

Collaborators

  • timhall