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");
Alternatively, attach a method to the native String.prototype
.
import { bindNative } from '@spartan-hc/holo-hash';
bindNative();
"uhCAkzycGKqICX7BJ11aehXkQ0ebZd9A0m08f-p8c1Pyy4uMlNUQU".toHoloHash();
API Reference
See docs/API.md
Contributing
See CONTRIBUTING.md