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

assets-hash-map

v1.1.3

Published

Command-line tool / Node.js utility to recursively generate maps of filepaths and sha-sums - comes in handy for cachebusting.

Downloads

8,006

Readme

assets-hash-map

Command-line tool / Node.js utility to recursively generate maps of filepaths and sha-sums - comes in handy for cachebusting.

Command-line
Install
npm install -g assets-hash-map
Simple usage
assets-hash-map my-dir
Example output:
{
  "public/assets/my-dir/image1.png": "b5e7a2060081a33477a98db33eac9ec4c59ba5db",
  "public/assets/my-dir/image2.png": "a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab",
  "public/assets/other-dir/my-font.woff": "a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab",
  "public/assets/other-dir/my-font.woff2": "a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab"
}
Command-line options
+--------------------------------+
|   Assets Hash Map generator:   |
+--------------------------------+

Generate a JSON assets hash map.
Usage: assets-hash-map [ paths ]

Options:
  -e, --extensions  Filter by file extension (comma separated)
  -x, --exclude     Exclude file extensions (comma separated)
  -b, --base-path   Set base path (filepaths will be relative to this)
  -s, --spaces      Tab spaces used formatting the JSON (defaults to 2)
  -o, --output      Output file (defaults to STDOUT)
  -a, --all         Include hidden files
  -h, --help        Show usage info

Example:
  assets-hash-map /dev/my-project/assets \\
    -e png,jpg,svg \\
    -x html,md \\
    -b /dev/my-project \\
    -s 0
    -o foo.json
Node.js API
Install
npm install assets-hash-map
getHashesMap(filepath)

Returns a Promise, which resolves with an Object containing the hash map for files in the given path.

Fails if called on an unexisting path.

Options:

  • include : {String[]} Only include these extensions (default: null)
  • exclude : {String[]} Extenstions to exclude (default: null)
  • absolute : {Boolean} Use absolute paths in map (default: false)
  • basePath : {String} Used to output relative paths (default: null)
  • all : {Boolean} Include hidden files (default: false)
Example
const { getHashesMap } = require('assets-hash-map')

getHashesMap('./my-project', { include: [ 'png', 'jpg' ] })
.then(hashesMap => {
  console.log(hashesMap)
})

// {
//   'public/assets/my-dir/image1.png': 'b5e7a2060081a33477a98db33eac9ec4c59ba5db',
//   'public/assets/my-dir/image2.png': 'a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab',
//   'public/assets/other-dir/image3.jpg': 'a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab',
//   'public/assets/other-dir/image4.jpg': 'a58bdd9dcc965d5b0f36b75f33a5fbcb6f2036ab'
// }