sum

sumchecker

Checksum checker for Node.js

Showing:

Popularity

Downloads/wk

131K

GitHub Stars

12

Maintenance

Last Commit

2mos ago

Contributors

7

Package

Dependencies

1

License

Apache-2.0

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

Sumchecker

Build
Status Code Coverage Dependency Status NPM package

Sumchecker is a pure Node.js solution to validating files specified in a checksum file, which are usually generated by programs such as sha256sum.

Requirements

sumchecker is tested with Node.js 12.13.0 (LTS) and above.

Usage

const sumchecker = require("sumchecker");

// NB: Top-level await is available in Node.js >= 14.8.0. Non-top-level-await syntax is left as an
// exercise to the reader.
try {
  await sumchecker(algorithm, checksumFilename, baseDir, filesToCheck);
  console.log("All files validate!");
} catch (error) {
  console.error("An error occurred", error);
}

Returns a Promise. The promise is resolved when all files specified in filesToCheck are validated. The promise is rejected otherwise.

Parameters

algorithm

String - The hash algorithm used in checksumFilename. Corresponds to the algorithms allowed by crypto.createHash().

checksumFilename

String - The path to the checksum file.

baseDir

String - The base directory for the files specified in filesToCheck.

filesToCheck

Array or String - one or more paths of the files that will be validated, relative to baseDir.

Errors

These are sumchecker-specific error classes that are passed to the promise's reject callback.

sumchecker.ChecksumMismatchError

When at least one of the files does not match its expected checksum.

Properties:

  • filename (String) - a path to a file that did not match

sumchecker.ChecksumParseError

When the checksum file cannot be parsed (as in, it does not match the checksum file format).

Properties:

  • lineNumber (Number) - the line number that could not be parsed
  • line (String) - the raw line data that could not be parsed, sans newline

sumchecker.NoChecksumFoundError

When at least one of the files specified to check is not listed in the checksum file.

Properties:

Security contact information

See SECURITY.md.

This library is copyrighted under the terms of the Apache 2.0 License.

Enterprise support

Available as part of the Tidelift Subscription.

The maintainers of sumchecker and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial