[Pkg-javascript-commits] [node-shasum] 10/23: deterministic tests passing with json-stable-stringify

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:06:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-shasum.

commit bc5f7bd24f568e6c7f4b666d5080bdad78a79fa6
Author: James Halliday <mail at substack.net>
Date:   Wed Jul 17 17:23:24 2013 -0700

    deterministic tests passing with json-stable-stringify
---
 index.js     | 4 +++-
 package.json | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index 989651f..4cf08e5 100644
--- a/index.js
+++ b/index.js
@@ -1,10 +1,12 @@
 
 var createHash = require('crypto').createHash 
 var Buffer = require('buffer').Buffer
+var stringify = require('json-stable-stringify')
+
 module.exports = function hash (str, alg, format) {
   str = 'string' === typeof str ? str
     : Buffer.isBuffer(str) ? str
-    : JSON.stringify(str)
+    : stringify(str)
   return createHash(alg || 'sha1')
     .update(str, Buffer.isBuffer(str) ? null : 'utf8').digest(format || 'hex')
 }
diff --git a/package.json b/package.json
index 35c5824..118356b 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
     "url": "git://github.com/dominictarr/shasum.git"
   },
   "dependencies": {
+    "json-stable-stringify": "~0.0.0"
   },
   "devDependencies": {
   },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shasum.git



More information about the Pkg-javascript-commits mailing list