Skip to content
Merged
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 lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports._getTmpname = getTmpname // for testing
module.exports._cleanupOnExit = cleanupOnExit

const fs = require('fs')
const MurmurHash3 = require('imurmurhash')
const crypto = require('node:crypto')
const { onExit } = require('signal-exit')
const path = require('path')
const { promisify } = require('util')
Expand All @@ -28,11 +28,13 @@ const threadId = (function getId () {
let invocations = 0
function getTmpname (filename) {
return filename + '.' +
MurmurHash3(__filename)
.hash(String(process.pid))
.hash(String(threadId))
.hash(String(++invocations))
.result()
crypto.createHash('sha1')
.update(__filename)
.update(String(process.pid))
.update(String(threadId))
.update(String(++invocations))
.digest()
.readUInt32BE(0)
}

function cleanupOnExit (tmpfile) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"homepage": "https://github.com/npm/write-file-atomic",
"dependencies": {
"imurmurhash": "^0.1.4",
"signal-exit": "^4.0.1"
},
"devDependencies": {
Expand Down