You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

@alcalzone/jsonl-db

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alcalzone/jsonl-db - npm Package Compare versions

Comparing version

to
1.2.5

@@ -15,2 +15,3 @@ "use strict";

const path = require("path");
const lockfile = require("proper-lockfile");
const readline = require("readline");

@@ -83,2 +84,19 @@ const stream = require("stream");

await fs.ensureDir(path.dirname(this.filename));
try {
await lockfile.lock(this.filename, {
// We cannot be sure that the file exists before acquiring the lock
realpath: false,
stale:
// Avoid timeouts during testing
process.env.NODE_ENV === "test"
? 100000
: /* istanbul ignore next - this is impossible to test */ undefined,
onCompromised: /* istanbul ignore next */ () => {
// do nothing
},
});
}
catch (e) {
throw new Error(`Failed to lock DB file "${this.filename}"!`);
}
this._fd = await fs.open(this.filename, "a+");

@@ -142,3 +160,3 @@ const readStream = fs.createReadStream(this.filename, {

}
const { onOpen, intervalMs, intervalMinChanges = 1 } = (_a = this.options.autoCompress) !== null && _a !== void 0 ? _a : {};
const { onOpen, intervalMs, intervalMinChanges = 1, } = (_a = this.options.autoCompress) !== null && _a !== void 0 ? _a : {};
// If the DB should be compressed while opening, do it before starting the write thread

@@ -302,3 +320,4 @@ if (onOpen) {

this.cork();
this._writeCorkTimeout = (_c = (_b = this._writeCorkTimeout) === null || _b === void 0 ? void 0 : _b.refresh()) !== null && _c !== void 0 ? _c : setTimeout(maybeUncork, this.options.throttleFS.intervalMs);
this._writeCorkTimeout =
(_c = (_b = this._writeCorkTimeout) === null || _b === void 0 ? void 0 : _b.refresh()) !== null && _c !== void 0 ? _c : setTimeout(maybeUncork, this.options.throttleFS.intervalMs);
}

@@ -511,2 +530,10 @@ /**

this._writeCorkCount = 0;
// Free the lock
try {
if (await lockfile.check(this.filename, { realpath: false }))
await lockfile.unlock(this.filename, { realpath: false });
}
catch (_b) {
// whatever - just don't crash
}
}

@@ -513,0 +540,0 @@ }

{
"name": "@alcalzone/jsonl-db",
"version": "1.2.4",
"version": "1.2.5",
"description": "Simple JSONL-based key-value store",

@@ -36,38 +36,34 @@ "main": "./build/index.js",

"devDependencies": {
"@alcalzone/release-script": "^1.8.3",
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.12",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.7",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.20",
"@alcalzone/release-script": "^1.10.0",
"@babel/cli": "^7.14.3",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@babel/preset-typescript": "^7.13.0",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@types/fs-extra": "^9.0.11",
"@types/jest": "^26.0.23",
"@types/mock-fs": "^4.13.0",
"@types/node": "^14.14.22",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"commitizen": "^4.2.3",
"@types/node": "^15.6.1",
"@types/proper-lockfile": "^4.1.1",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"commitizen": "^4.2.4",
"coveralls": "^3.1.0",
"eslint": "^7.19.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^4.3.8",
"jest": "^26.6.3",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"jest": "^27.0.1",
"jest-extended": "^0.11.5",
"mock-fs": "^4.13.0",
"prettier": "^2.2.1",
"mock-fs": "^4.14.0",
"prettier": "^2.3.0",
"source-map-support": "^0.5.19",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
"typescript": "^4.3.2"
},
"dependencies": {
"alcalzone-shared": "^3.0.2",
"fs-extra": "^9.1.0"
"alcalzone-shared": "^3.0.4",
"fs-extra": "^9.1.0",
"proper-lockfile": "^4.1.2"
},

@@ -88,9 +84,5 @@ "scripts": {

"commit": "git-cz",
"release": "release-script"
"release": "release-script",
"prepare": "husky install"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {

@@ -97,0 +89,0 @@ "commitizen": {

@@ -136,2 +136,4 @@ # jsonl-db

-->
### 1.2.5 (2021-05-29)
Prevent opening one DB file in multiple instances of the DB using lockfiles

@@ -138,0 +140,0 @@ ### 1.2.4 (2021-02-15)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet