npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@objekt/checksum-report

v1.0.1

Published

NodeJS utility library to generate checksums for files and directories.

Downloads

1

Readme

Introduction

This utility libary assists you to generate a checksum report for a directory and its descendants.

This is useful to include in the root of distribution bundle, e.g. a static website, as a client application could use this report to validate it has downloaded the complete bundle.

Each file in the directory structure is read and its content hashed using the sha1 algorithm with hex encoding by default.

The report is generated as a JSON string in the below format, where:

  • id = uniquely identifies the report, i.e. the overall hash of all file hashes.
  • timestamp = the timestamp on which the report was generated.
  • files = is a flat array of each path and it's hash.

e.g.

{
  "id":"9d307fdcafb3f6f2fbcd47899df78652936cea00",
  "timestamp":"2022-04-10T15:21:08.406Z",
  "files":[
    {
      "path":"index.html",
      "hash":"064c47308009992f133a44e368cf1dcfdaa9d85e"
    },
    {
      "path":"app.39b812d9.js",
      "hash":"1bd6e3344fbc3363b1faa00d1115378135aac5ce"
    },
    {
      "path":"vendors.70682963.js",
      "hash":"5b055ca612c8e6883decd76258261d85da3de644"
    },
    {
      "path":"assets/logo.png",
      "hash":"ed73e59a43d571044f457e62d385a6ea025f651c"
    }
  ]
}

Installation

npm install @objekt/checksum-report

Configuration

No configuration needed. This libary targets NodeJS 16 and above.

Usage

Generate Checksum Report

Generate a checksum report for the dist directory.

import { ChecksumReport } from '@objekt/checksum-report';

const report = await ChecksumReport.get('./dist');

console.log(report);

Generate and Save Checksum Report to Disk

Generate and save a checksum for the dist directory as checksum.json to disk.

import { ChecksumReport } from '@objekt/checksum-report';

const report = await ChecksumReport.save('./dist', './dist/checksum.json');

console.log(report);

API Reference

Full API documentation here.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind welcome! (emoji key)

License

MIT