Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alcalzone/jsonl-db

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alcalzone/jsonl-db - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

6

build/lib/db.d.ts

@@ -57,2 +57,7 @@ export interface JsonlDBOptions<V> {

};
/**
* Override in which directory the lockfile is created.
* Defaults to the directory in which the DB file is located.
*/
lockfileDirectory?: string;
}

@@ -75,2 +80,3 @@ /** This is the same as `fs-extra`'s WriteOptions */

readonly backupFilename: string;
private readonly lockfileName;
private options;

@@ -77,0 +83,0 @@ private _db;

24

build/lib/db.js

@@ -54,2 +54,5 @@ "use strict";

this.backupFilename = this.filename + ".bak";
this.lockfileName = options.lockfileDirectory
? path.join(options.lockfileDirectory, path.basename(this.filename))
: this.filename;
this.options = options;

@@ -111,3 +114,4 @@ // Bind all map properties we can use directly

try {
await lockfile.lock(this.filename, {
await fs.ensureDir(path.dirname(this.lockfileName));
await lockfile.lock(this.lockfileName, {
// We cannot be sure that the file exists before acquiring the lock

@@ -126,3 +130,3 @@ realpath: false,

catch (e) {
throw new Error(`Failed to lock DB file "${this.filename}"!`);
throw new Error(`Failed to lock DB file "${this.lockfileName}"!`);
}

@@ -195,3 +199,3 @@ // If the application crashed previously, try to recover from it

// Start the write thread
this._openPromise = deferred_promise_1.createDeferredPromise();
this._openPromise = (0, deferred_promise_1.createDeferredPromise)();
void this.writeThread();

@@ -372,3 +376,3 @@ await this._openPromise;

}
return fs.writeJSON(filename, objects_1.composeObject([...this._db]), options);
return fs.writeJSON(filename, (0, objects_1.composeObject)([...this._db]), options);
}

@@ -485,3 +489,3 @@ updateStatistics(command) {

async dump() {
this._dumpPromise = deferred_promise_1.createDeferredPromise();
this._dumpPromise = (0, deferred_promise_1.createDeferredPromise)();
// Open the file for writing (or truncate if it exists)

@@ -518,3 +522,3 @@ this._dumpFd = await fs.open(this.dumpFilename, "w+");

this.autoCork();
this._writePromise = deferred_promise_1.createDeferredPromise();
this._writePromise = (0, deferred_promise_1.createDeferredPromise)();
// Open the file for appending and reading

@@ -549,3 +553,3 @@ this._fd = await fs.open(this.filename, "a+");

return;
this.compressPromise = deferred_promise_1.createDeferredPromise();
this.compressPromise = (0, deferred_promise_1.createDeferredPromise)();
// Immediately remember the database size or writes while compressing

@@ -580,3 +584,3 @@ // will be incorrectly reflected

// Start the write thread again
this._openPromise = deferred_promise_1.createDeferredPromise();
this._openPromise = (0, deferred_promise_1.createDeferredPromise)();
void this.writeThread();

@@ -643,4 +647,4 @@ await this._openPromise;

try {
if (await lockfile.check(this.filename, { realpath: false }))
await lockfile.unlock(this.filename, { realpath: false });
if (await lockfile.check(this.lockfileName, { realpath: false }))
await lockfile.unlock(this.lockfileName, { realpath: false });
}

@@ -647,0 +651,0 @@ catch {

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

@@ -36,32 +36,33 @@ "main": "./build/index.js",

"devDependencies": {
"@alcalzone/release-script": "^1.10.0",
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.14.5",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@alcalzone/release-script": "~3.4.0",
"@alcalzone/release-script-plugin-license": "~3.3.0",
"@babel/cli": "^7.14.8",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@tsconfig/node12": "^1.0.9",
"@types/fs-extra": "^9.0.11",
"@types/jest": "^26.0.23",
"@types/mock-fs": "^4.13.0",
"@types/node": "^15.12.4",
"@types/proper-lockfile": "^4.1.1",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.0.1",
"@types/mock-fs": "^4.13.1",
"@types/node": "^16.10.2",
"@types/proper-lockfile": "^4.1.2",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"commitizen": "^4.2.4",
"coveralls": "^3.1.0",
"eslint": "^7.29.0",
"coveralls": "^3.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"jest": "^27.0.5",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.2",
"jest": "^27.1.0",
"jest-extended": "^0.11.5",
"prettier": "^2.3.1",
"prettier": "^2.4.1",
"source-map-support": "^0.5.19",
"ts-node": "^10.0.0",
"typescript": "^4.3.4"
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"dependencies": {
"alcalzone-shared": "^3.0.4",
"alcalzone-shared": "^4.0.0",
"fs-extra": "^10.0.0",

@@ -68,0 +69,0 @@ "proper-lockfile": "^4.1.2"

@@ -85,2 +85,10 @@ # jsonl-db

### Changing where the lockfile is created
Normally, the lockfile to avoid concurrent access to the DB file is created right next to the DB file. You can change this, e.g. to put the lockfile into a `tmpfs`:
```ts
const db = new DB("/path/to/file", { lockfileDirectory: "/var/tmp" });
```
If the directory does not exist, it will be created when opening the DB.
### Copying and compressing the database

@@ -137,2 +145,5 @@

-->
### 2.2.0 (2021-10-15)
* Add the ability to specify where the lockfile is created
### 2.1.0 (2021-06-22)

@@ -207,2 +218,2 @@ * When opening the DB, recover from crashes that happened while compressing the DB

### 0.1.0 (2020-04-25)
First official release
First official release

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc