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

any_sha1

v0.1.1

Published

JavaScript functions for abstracting SHA1 implementations

Downloads

6

Readme

any_sha1

This package provides JavaScript functions for abstracting SHA-1 implementations, providing a uniform signature and interface.

When module is defined, this function will require and use the crypto module to produce the SHA-1 hash.

Otherwise, it will detect and use SHA-1 functions from the following projects, in order:

(Pull requests to add more implementations are welcome.)

any_sha1.from(opts)

Detects for the presence of the projects listed above, and returns the first function from opts that matches a detected environment (or null, if no recognized SHA-1 implementation was found).

The "opts" parameter is expected to come from one of the sets defined below, where the first level is the input encoding to hash (eg. 'utf8') and the second level is the output type (eg. 'bytes' for an array of byte values).

any_sha1.define(opts,[obj,[key,[chooser]]])

Defines key (by default, sha1) in obj (by default, window) to the function in opts selected by chooser (by default, any_sha1.from).

If no appropriate SHA-1 function is found (chooser(opts) returns null), this function will return / define a function that will attept to define the SHA-1 function when first called, allowing for a late-binding approach where the appropriate SHA-1 implementation is introduced after this function is invoked.

Input encodings: any_sha1.utf8

Output options under this encoding type treat extended characters in the given string outside the ASCII set as their UTF-8 byte representations. (Due to the modern ubiquity of the UTF-8 encoding, nowadays, this is usually what you want: as such, for the moment, this is the only input encoding this package provides.)

For SHA-1 functions that don't handle strings with character codes outside the 0-255 range (pretty much all of them), the string will first be converted to UTF-8 via the unescape-encodeURIComponent method.

Output options: any_sha1.utf8.bytes

Returns the SHA-1 hash as an array of byte values.

Example usage

To define a default SHA-1 function for hashblot, allowing for late binding:

any_sha1.define(any_sha1.utf8.bytes, hashblot);