Verified Commit 4ecab666 authored by Aral Balkan's avatar Aral Balkan
Browse files

Perform writes using write-file-atomic

parent 142e5d35
......@@ -17,7 +17,7 @@ const path = require('path')
const { log, needsToBeProxified } = require('./util')
const isProxy = require('util').types.isProxy
const { promisify } = require('util')
const fastWriteAtomic = promisify(require('fast-write-atomic'))
const writeFileAtomic = require('write-file-atomic')
const { performance } = require('perf_hooks')
......@@ -139,7 +139,7 @@ class WhatTable {
const tableContents = JSON.stringify(this.dataProxy)
const t2 = performance.now()
log(` 💾 ❨WhatDB?❩ ╰─ Stringified in ${(t2-t1).toFixed(3)} ms.`)
await fastWriteAtomic(this.tablePath, tableContents)
await writeFileAtomic(this.tablePath, tableContents)
const t3 = performance.now()
log(` 💾 ❨WhatDB?❩ ╰─ Wrote in ${(t3-t2).toFixed(3)} ms.`)
this.isSaving = false
......
......@@ -788,8 +788,7 @@
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
"dev": true
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
},
"indent-string": {
"version": "4.0.0",
......@@ -924,8 +923,7 @@
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
},
"is-weakmap": {
"version": "2.0.1",
......@@ -1537,8 +1535,7 @@
"signal-exit": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz",
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==",
"dev": true
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA=="
},
"source-map": {
"version": "0.5.7",
......@@ -1908,7 +1905,6 @@
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"dev": true,
"requires": {
"is-typedarray": "^1.0.0"
}
......@@ -2032,7 +2028,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz",
"integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==",
"dev": true,
"requires": {
"imurmurhash": "^0.1.4",
"is-typedarray": "^1.0.0",
......
......@@ -27,7 +27,8 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"fast-write-atomic": "^0.2.1",
"fs-extra": "^9.0.1"
"fs-extra": "^9.0.1",
"write-file-atomic": "^3.0.3"
},
"devDependencies": {
"nyc": "^15.1.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment