How to use the node-object-hash/objectSorter function in node-object-hash

To help you get started, we’ve selected a few node-object-hash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github isoreact / core / src / key-for.js View on Github external
import objectSorter from 'node-object-hash/objectSorter';
import sha256 from 'hash.js/lib/hash/sha/256';

const sortObject = objectSorter();

const hashObject = (props) => (
    sha256()
        .update(sortObject(props))
        .digest('hex')
);

/**
 * Generate a <code>hydration</code> key based on an isomorphic component name and the props of one of its instances
 * or nested isomorphic component instances.
 *
 * @param {string} name  - isomorphic component name
 * @param {Object} props - isomorphic component instance props
 * @return {string} the hydration key
 */
export default function keyFor(name, props) {

node-object-hash

Node.js object hash library with properties/arrays sorting to provide constant hashes

MIT
Latest version published 5 days ago

Package Health Score

89 / 100
Full package analysis