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

lmdb

Package Overview
Dependencies
Maintainers
3
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lmdb - npm Package Compare versions

Comparing version 2.6.0-alpha4 to 2.6.0-alpha5

24

index.d.ts

@@ -84,3 +84,3 @@ declare namespace lmdb {

/**
* Syncronously store the provided value, using the provided id/key, will return after the data has been written.
* Synchronously store the provided value, using the provided id/key, will return after the data has been written.
* @param id The key for the entry

@@ -91,3 +91,3 @@ * @param value The value to store

/**
* Syncronously store the provided value, using the provided id/key and version number
* Synchronously store the provided value, using the provided id/key and version number
* @param id The key for the entry

@@ -99,3 +99,3 @@ * @param value The value to store

/**
* Syncronously store the provided value, using the provided id/key and options
* Synchronously store the provided value, using the provided id/key and options
* @param id The key for the entry

@@ -107,3 +107,3 @@ * @param value The value to store

/**
* Syncronously remove the entry with the provided id/key
* Synchronously remove the entry with the provided id/key
* existing version

@@ -162,3 +162,3 @@ * @param id The key for the entry to remove

/**
* Execute a transaction asyncronously, running all the actions within the action callback in the transaction,
* Execute a transaction asynchronously, running all the actions within the action callback in the transaction,
* and committing the transaction after the action callback completes.

@@ -170,3 +170,3 @@ * existing version

/**
* Execute a transaction syncronously, running all the actions within the action callback in the transaction,
* Execute a transaction synchronously, running all the actions within the action callback in the transaction,
* and committing the transaction after the action callback completes.

@@ -179,3 +179,3 @@ * existing version

/**
* Execute a transaction asyncronously, running all the actions within the action callback in the transaction,
* Execute a transaction asynchronously, running all the actions within the action callback in the transaction,
* and committing the transaction after the action callback completes.

@@ -187,2 +187,7 @@ * existing version

/**
* Returns the current transaction and marks it as in use. This can then be explicitly used for read operations
* @returns The transaction object
**/
useReadTransaction(): Transaction
/**
* Execute a set of write operations that will all be batched together in next queued asynchronous transaction.

@@ -354,2 +359,4 @@ * @param action The function to execute with a set of write operations.

snapshot?: boolean
/** Use the provided transaction for this range query */
transaction: Transaction
}

@@ -383,2 +390,5 @@ interface PutOptions {

}
class Transaction {
use<T>(callback: () => T): T
}
export function getLastVersion(): number

@@ -385,0 +395,0 @@ export function compareKeys(a: Key, b: Key): number

{
"name": "lmdb",
"author": "Kris Zyp",
"version": "2.6.0-alpha4",
"version": "2.6.0-alpha5",
"description": "Simple, efficient, scalable, high-performance LMDB interface",

@@ -65,4 +65,4 @@ "license": "MIT",

"prebuild-libc-arm7": "prebuildify-platform-packages --napi --platform-packages --tag-libc --target 16.16.0",
"prebuildify": "prebuildify-platform-packages --target 18.6.0",
"full-publish": "cd prebuilds/win32-x64 && npm publish --access public && cd ../darwin-x64 && npm publish --access public && cd ../darwin-arm64 && npm publish --access public && cd ../linux-x64 && npm publish --access public && cd ../linux-arm64 && npm publish --access public && cd ../linux-arm && npm publish --access public && cd ../.. && npm publish --tag alpha",
"prebuildify": "prebuildify-platform-packages --napi --target 18.6.0",
"full-publish": "cd prebuilds/win32-x64 && npm publish --access public && cd ../darwin-x64 && npm publish --access public && cd ../darwin-arm64 && npm publish --access public && cd ../linux-x64 && npm publish --access public && cd ../linux-arm64 && npm publish --access public && cd ../linux-arm && npm publish --access public && cd ../.. && npm publish",
"recompile": "node-gyp clean && node-gyp configure && node-gyp build",

@@ -80,3 +80,3 @@ "test": "mocha test/**.test.js --expose-gc --recursive && npm run test:types",

"node-gyp-build-optional-packages": "5.0.3",
"ordered-binary": "^1.2.4",
"ordered-binary": "^1.3.0",
"weak-lru-cache": "^1.2.2"

@@ -104,9 +104,9 @@ },

"optionalDependencies": {
"@lmdb/lmdb-darwin-arm64": "2.6.0-alpha4",
"@lmdb/lmdb-darwin-x64": "2.6.0-alpha4",
"@lmdb/lmdb-linux-arm": "2.6.0-alpha4",
"@lmdb/lmdb-linux-arm64": "2.6.0-alpha4",
"@lmdb/lmdb-linux-x64": "2.6.0-alpha4",
"@lmdb/lmdb-win32-x64": "2.6.0-alpha4"
"@lmdb/lmdb-darwin-arm64": "2.6.0-alpha5",
"@lmdb/lmdb-darwin-x64": "2.6.0-alpha5",
"@lmdb/lmdb-linux-arm": "2.6.0-alpha5",
"@lmdb/lmdb-linux-arm64": "2.6.0-alpha5",
"@lmdb/lmdb-linux-x64": "2.6.0-alpha5",
"@lmdb/lmdb-win32-x64": "2.6.0-alpha5"
}
}
import { RangeIterable } from './util/RangeIterable.js';
import { getAddress, Cursor, Txn, orderedBinary, lmdbError, getByBinary, detachBuffer, setGlobalBuffer, prefetch, iterate, position as doPosition, resetTxn, getCurrentValue, getCurrentShared, getStringByBinary, globalBuffer, getSharedBuffer, startRead } from './native.js';
import { saveKey } from './keys.js';
const IF_EXISTS = 3.542694326329068e-103;
const ITERATOR_DONE = { done: true, value: undefined };

@@ -22,3 +23,3 @@ const Uint8ArraySlice = Uint8Array.prototype.slice;

}) {
let readTxn, readTxnRenewed, asSafeBuffer = false;
let readTxn, explicitTxn, readTxnRenewed, asSafeBuffer = false;
let renewId = 1;

@@ -28,4 +29,4 @@ let mmaps = [];

getString(id) {
(env.writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(this)));
let string = getStringByBinary(this.dbAddress, this.writeKey(id, keyBytes, 0));
let txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
let string = getStringByBinary(this.dbAddress, this.writeKey(id, keyBytes, 0), txn.address);
if (typeof string === 'number') { // indicates the buffer wasn't large enough

@@ -42,8 +43,4 @@ this._allocateGetBuffer(string);

let rc;
if (options?.txn?.address)
rc = this.lastSize = getByBinary(this.dbAddress, this.writeKey(id, keyBytes, 0), options.ifNotTxnId || 0, options.txn.address);
else {
(env.writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(this)));
rc = this.lastSize = getByBinary(this.dbAddress, this.writeKey(id, keyBytes, 0), options?.ifNotTxnId || 0, 0);
}
let txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
rc = this.lastSize = getByBinary(this.dbAddress, this.writeKey(id, keyBytes, 0), options?.ifNotTxnId || 0, txn.address || 0);
if (rc < 0) {

@@ -78,3 +75,3 @@ if (rc == -30798) // MDB_NOTFOUND

getBFAsync(id, callback, options) {
let txn = options?.txn || (env.writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(this)));
let txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
let address = recordReadInstruction(txn.address, this.db.dbi, id, this.writeKey, maxKeySize, ({ bufferId, offset, size }) => {

@@ -112,4 +109,5 @@ let buffer = mmaps[bufferId];

if (!buffer.isGlobal && !env.writeTxn) {
buffer.txn = readTxn;
readTxn.refCount = (readTxn.refCount || 0) + 1;
let txn = explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
buffer.txn = txn;
txn.refCount = (txn.refCount || 0) + 1;
return buffer;

@@ -194,4 +192,4 @@ } else {

return Uint8ArraySlice.call(fastBuffer, 0, this.lastSize)
fastBuffer.txn = readTxn;
readTxn.refCount = (readTxn.refCount || 0) + 1;
fastBuffer.txn = explicitTxn;
explicitTxn.refCount = (explicitTxn.refCount || 0) + 1;
return fastBuffer;

@@ -254,4 +252,2 @@ }

doesExist(key, versionOrValue) {
if (!env.writeTxn)
readTxnRenewed ? readTxn : renewReadTxn(this);
if (versionOrValue == null) {

@@ -262,4 +258,3 @@ // undefined means the entry exists, null is used specifically to check for the entry *not* existing

else if (this.useVersions) {
this.getBinaryFast(key);
return this.getBinaryFast(key) !== undefined && getLastVersion() === versionOrValue;
return this.getBinaryFast(key) !== undefined && (versionOrValue === IF_EXISTS || getLastVersion() === versionOrValue);
}

@@ -338,7 +333,14 @@ else {

finishCursor();
let writeTxn = env.writeTxn;
if (writeTxn)
snapshot = false;
txn = writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(store));
cursor = !writeTxn && db.availableCursor;
let txnAddress;
if (options.transaction) {
txn = options.transaction;
txnAddress = txn.address;
cursor = null;
} else {
let writeTxn = env.writeTxn;
if (writeTxn)
snapshot = false;
txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(store));
cursor = !writeTxn && db.availableCursor;
}
if (cursor) {

@@ -348,3 +350,3 @@ db.availableCursor = null;

} else {
cursor = new Cursor(db);
cursor = new Cursor(db, txnAddress);
}

@@ -355,3 +357,3 @@ cursorAddress = cursor.address;

cursorRenewId = renewId; // use shared read transaction
txn.renewingrefCount = (txn.renewingrefCount || 0) + 1; // need to know how many are renewing cursors
txn.renewingRefCount = (txn.renewingRefCount || 0) + 1; // need to know how many are renewing cursors
}

@@ -408,3 +410,3 @@ } catch(error) {

if (cursorRenewId)
txn.renewingrefCount--;
txn.renewingRefCount--;
if (--txn.refCount <= 0 && txn.onlyCursor) {

@@ -539,3 +541,3 @@ cursor.close();

getSharedBufferForGet(id) {
let txn = (env.writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(this)));
let txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
this.lastSize = this.keyIsCompatibility ? txn.getBinaryShared(id) : this.db.get(this.writeKey(id, keyBytes, 0));

@@ -597,5 +599,18 @@ if (this.lastSize === -30798) { // not found code

},
useReadTxn() {
let txn = readTxnRenewed ? readTxn : renewReadTxn(this);
startReadTransaction() {
let txn = explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
txn.refCount = (txn.refCount || 0) + 1;
txn.use = function(action) {
let lastTxn = explicitTxn;
explicitTxn = this;
try {
return action();
} finally {
explicitTxn = lastTxn;
}
};
txn.done = function() {
txn.refCount--;
// TODO: if zero, and onlyCursor, abort it
};
},

@@ -635,3 +650,3 @@ close(callback) {

getStats() {
(env.writeTxn || (readTxnRenewed ? readTxn : renewReadTxn(this)));
let txn = env.writeTxn || explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));
let dbStats = this.db.stat();

@@ -684,12 +699,13 @@ dbStats.root = env.stat();

}
function resetReadTxn(hardReset) {
function resetReadTxn() {
renewId++;
if (readTxnRenewed) {
readTxnRenewed = null;
if (readTxn.refCount - (readTxn.renewingrefCount || 0) > 0) {
if (readTxn.refCount - (readTxn.renewingRefCount || 0) > 0) {
readTxn.onlyCursor = true;
lastReadTxnRef = new WeakRef(readTxn);
readTxn = null;
} else
} else {
resetTxn(readTxn.address);
}
}

@@ -696,0 +712,0 @@ }

@@ -68,2 +68,3 @@ import { getAddress, write, compress } from './native.js';

var writeBatchStart, outstandingBatchCount, lastSyncTxnFlush, lastFlushTimeout, lastFlushCallback;
var hasUnresolvedTxns;
txnStartThreshold = txnStartThreshold || 5;

@@ -374,6 +375,10 @@ batchStartThreshold = batchStartThreshold || 1000;

}
break;
case 1:
console.log('unknown status', status);
break;
case 2:
hasUnresolvedTxns = false;
executeTxnCallbacks();
return hasUnresolvedTxns;
break;

@@ -529,2 +534,3 @@ default:

// must complete any outstanding transactions before proceeding
hasUnresolvedTxns = true;
await Promise.all(promises);

@@ -539,2 +545,3 @@ promises = null;

if (result && result.then) {
hasUnresolvedTxns = true;
await result;

@@ -570,5 +577,9 @@ }

if (promises) { // finish any outstanding commit functions
hasUnresolvedTxns = true;
await Promise.all(promises);
}
clearWriteTxn(null);
if (hasUnresolvedTxns) {
env.resumeWriting();
}
function txnError(error, i) {

@@ -590,3 +601,3 @@ (txnCallbacks.errors || (txnCallbacks.errors = []))[i] = error;

// close them.
if (writeTxn.refCount > 0)
if (writeTxn && writeTxn.refCount > 0)
writeTxn.isDone = true;

@@ -593,0 +604,0 @@ env.writeTxn = writeTxn = parentTxn || null;

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

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

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