Skip to content

User murmur instead of md5 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
'use strict'
var fs = require('graceful-fs');
var chain = require('slide').chain;
var crypto = require('crypto');
var MurmurHash3 = require('imurmurhash');

var md5hex = function () {
var hash = crypto.createHash('md5');
for (var ii=0; ii<arguments.length; ++ii) hash.update(''+arguments[ii])
return hash.digest('hex')
function murmurhex () {
var hash = MurmurHash3('');
for (var ii=0; ii<arguments.length; ++ii) {
hash.hash(hash+arguments[ii]);
}
return hash.result();
}
var invocations = 0;
var getTmpname = function (filename) {
return filename + "." + md5hex(__filename, process.pid, ++invocations)
return filename + "." + murmurhex(__filename, process.pid, ++invocations)
}

module.exports = function writeFile(filename, data, options, callback) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"homepage": "https://github.com/iarna/write-file-atomic",
"dependencies": {
"graceful-fs": "^4.1.2",
"slide": "^1.1.5"
"slide": "^1.1.5",
"imurmurhash": "^0.1.4"
},
"devDependencies": {
"require-inject": "^1.1.0",
Expand Down