Comparing version 1.0.1 to 1.0.2
@@ -26,3 +26,3 @@ 'use strict'; | ||
function foldObject (hash, o, seen) { | ||
return Object.keys(o).reduce(foldKey, hash); | ||
return Object.keys(o).sort().reduce(foldKey, hash); | ||
function foldKey (hash, key) { | ||
@@ -29,0 +29,0 @@ return foldValue(hash, o[key], key, seen); |
{ | ||
"name": "hash-sum", | ||
"description": "Blazing fast unique hash generator", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/bevacqua/hash-sum", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -11,2 +11,12 @@ # hash-sum | ||
# features | ||
- no dependencies | ||
- minimal footprint | ||
- works in all of node.js, io.js, and the browser | ||
- hashes functions based on their source code | ||
- produces different hashes for different object types | ||
- support for circular references in objects | ||
- ignores property assignment order | ||
# `sum(value)` | ||
@@ -50,3 +60,2 @@ | ||
3718c6e8 from: { a: {}, b: {} } | ||
caec4ca8 from: { b: {}, a: {} } | ||
5d844489 from: [] | ||
@@ -53,0 +62,0 @@ 938eaaf0 from: Tue Jul 14 2015 15:35:36 GMT-0300 (ART) |
15
test.js
@@ -5,6 +5,6 @@ 'use strict'; | ||
var test = require('tape'); | ||
var results = []; | ||
var sum = require('./'); | ||
test('creates unique hashes', function (t) { | ||
var sum = require('./'); | ||
var results = []; | ||
sub([0,1,2,3]); | ||
@@ -41,3 +41,2 @@ sub({url:12}); | ||
sub({a:{},b:{}}); | ||
sub({b:{},a:{}}); | ||
sub([]); | ||
@@ -55,1 +54,11 @@ sub(new Date()); | ||
}); | ||
test('hashes clash if same properties', function (t) { | ||
equals({a:'1'},{a:'1'}); | ||
equals({a:'1',b:1},{b:1,a:'1'}); | ||
t.end(); | ||
function equals (a, b) { | ||
t.equal(sum(a), sum(b)); | ||
} | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6492
107
68