Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
node-object-hash example
node v6.17.1
version:
1.0.2
endpoint
share
tweet
Simple usage example of node-object-hash library
const hasher = require('node-object-hash')({sort:true, coerce:true}); const assert = require('assert'); const a = [true, null, {b:2, a:1, c:3}, 5, 'a', 6, 2]; const b = [{c:3, 'a':true, b:2}, 1, undefined, "6", 5, '2', "a"]; console.log('Sorted string of {a}:', hasher.sortObject(a)); console.log('Sorted string of {b}:', hasher.sortObject(b)); assert.ok(hasher.hash(a) === hasher.hash(b), 'Objects a and b should have equal hashes'); console.log('Hashes are equal');
Loading…
no comments
sign in
to comment