JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15362
  • Score
    100M100P100Q133101F
  • License MIT

A Node.js module that hashes JavaScript objects.

Package Exports

  • hash-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hash-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hash-object

Build Status

A Node.js module that hashes JavaScript objects.

Getting Started

Install the module with: npm install hash-object

Documentation

hashObject(obj, [opts])

var hashObject = require('hash-object');
  • obj: the object to be hashed
  • opts: options for the hashing function
    • algorithm: dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha1' (default), 'md5', 'sha256', 'sha512', etc.

Examples

Simple Compare

var hash1 = hashObject({
    a: 'b',
    c: 'd',
    e: 'f'
});
var hash2 = hashObject({
    a: 'b',
    e: 'f',
    c: 'd'
});

// hash1 === hash2

Complex Compare

var hash3 = hashObject({
    a: 'b',
    b: ['c', 'd'],
    c: {
        d: 'e',
        f: {
            g: 'h'
        }
    }
});
var hash4 = hashObject({
    a: 'b',
    c: {
        f: {
            g: 'h'
        },
        d: 'e'
    },
    b: ['c', 'd']
});

// hash3 === hash4

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 David Caseria
Licensed under the MIT license.