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

@spartan-hc/holo-hash

v0.7.0

Published

A Javascript library for managing Holochain's HoloHash types

Downloads

202

Readme

new HoloHash( input )

A Javascript library for managing Holochain's HoloHash types.

Overview

This module is intended to provide Javascript classes for managing the various HoloHash types. It is designed to resemble the struct names and implementations based on Holochain's holo_hash crate (https://crates.io/crates/holo_hash). Although, method names and formats have been modified to match Javascript's architecture.

Features

  • Construct from a 32-byte raw hash
  • Construct from a 36-byte raw hash + DHT address
  • Construct from a 39-byte full Holo Hash
  • Parse from the Holo Hash string representation (eg. uhCAkzycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU)
  • Parse from a url-safe-base64 string (no leading u)
    • eg. 32-byte zycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uM
    • eg. 36-byte zycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU
    • eg. 39-byte hCAkzycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU
  • Custom error classes (similar to the holo_hash crate)
  • Proper class inheritance for using instanceof
    • eg. (new AgentPubKey(...) instanecof HoloHash) === true
    • eg. (new AgentPubKey(...) instanecof AnyDhtHash) === true
    • eg. (new AgentPubKey(...) instanecof AgentPubKey) === true
    • eg. (new AgentPubKey(...) instanecof EntryHash) === false

Install

npm i @spartan-hc/holo-hash

Basic Usage

import { HoloHash } from '@spartan-hc/holo-hash';

new HoloHash("uhCAkzycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU");
// AgentPubKey(39) [
//   132,  32,  36, 207,  39,   6,  42, 162,  2,
//    95, 176,  73, 215,  86, 158, 133, 121, 16,
//   209, 230, 217, 119, 208,  52, 155,  79, 31,
//   250, 159,  28, 212, 252, 178, 226, 227, 37,
//    53,  68,  20
// ]

Alternatively, attach a method to the native String.prototype.

import { bindNative } from '@spartan-hc/holo-hash';

bindNative();

"uhCAkzycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU".toHoloHash();
// AgentPubKey(39) [
//   132,  32,  36, 207,  39,   6,  42, 162,  2,
//    95, 176,  73, 215,  86, 158, 133, 121, 16,
//   209, 230, 217, 119, 208,  52, 155,  79, 31,
//   250, 159,  28, 212, 252, 178, 226, 227, 37,
//    53,  68,  20
// ]

API Reference

See docs/API.md

Contributing

See CONTRIBUTING.md