Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

all-terrain-hash

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

all-terrain-hash

All Terrain Object Hashing

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

all-terrain-hash stability

npm version downloads js-standard-style

All Terrain Object Hashing.

Hash any javascript object, functions, undefined, warts and all. This utility takes any javascript object and hashes it in a reproducible deterministic way. Functions are decomposed into an AST, with comments and whitespace discarded. Objects are ordered in a consistent and safe way. It even takes into account the difference between an undefined and a null.

Why?

Sometimes you need to know when anything is different. For instance, if you are handling code across distributed services, or doing stuff that git should be responsible for ;)

Usage

const ath = require('all-terrain-hash')

let exampleObject = {
  "I've got a nice long key name": function withAFunction (a, b, c=3) {
    return "Why, how nice this all is today. I hope we do not get crushed into a hash string."
  },
  "Sure we won't": (world)=>this,
  "question": {"Have you seen my mirror?": {"response": "Why yes, I have, let me get it for you."}}
}
exampleObject.question.response.mirror = exampleObject

ath.hex(exampleObject)
// 'ab1934e351c6a2e99ab84e18eef04bfc2963896e4a75a76a99af84e7a00be6738d9f2f35b9aa322f5f4a1d7f82a037ee082658af08708e2175a4b63539f280f0'

ath(exampleObject)
// Uint8Array 
// Blake2b { digestLength: 64, finalized: false, pointer: 64 }

API

ath(obj, [key], [salt], [personal])

This takes an ordinary object and will deterministically hash it via blake2b. It returns a Uint8Array by default. All optionals arguments such as key, salt, and personal will be passed to blake2b.

.hex(obj, [key], [salt], [personal])

This takes an ordinary object and will deterministically hash it via blake2b. Unlike the function above, it returns it as a hex string. All optionals arguments such as key, salt, and personal will be passed to blake2b.

Installation

$ npm install all-terrain-hash

License

MIT

Keywords

FAQs

Package last updated on 16 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc