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

lmdb

Package Overview
Dependencies
Maintainers
3
Versions
174
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-beta1 to 2.6.0

24

index.d.ts

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

**/
get(id: K): V | undefined
get(id: K, options?: GetOptions): V | undefined
/**

@@ -132,3 +132,3 @@ * Get the entry stored by given id/key, which includes both the value and the version number (if available)

**/
getValues(key: K, options?: RangeOptions): ArrayLikeIterable<V>
getValues(key: K, options?: RangeOptions): RangeIterable<V>
/**

@@ -145,3 +145,3 @@ * Get the count of all the values for the given key (for dupsort databases)

**/
getKeys(options?: RangeOptions): ArrayLikeIterable<K>
getKeys(options?: RangeOptions): RangeIterable<K>
/**

@@ -158,3 +158,3 @@ * Get the count of all the unique keys for the given range

**/
getRange(options?: RangeOptions): ArrayLikeIterable<{ key: K, value: V, version?: number }>
getRange(options?: RangeOptions): RangeIterable<{ key: K, value: V, version?: number }>
/**

@@ -280,4 +280,6 @@ * Get the count of all the entries for the given range

* Make a snapshot copy of the current database at the indicated path
* @param path Path to store the backup
* @param compact Apply compaction while making the backup (slower and smaller)
**/
backup(path: string): Promise<void>
backup(path: string, compact: boolean): Promise<void>
/**

@@ -350,2 +352,4 @@ * Close the current database.

}
interface GetOptions {
}
interface RangeOptions {

@@ -367,3 +371,3 @@ /** Starting key for a range **/

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

@@ -390,5 +394,7 @@ interface PutOptions {

}
class ArrayLikeIterable<T> implements Iterable<T> {
map<U>(callback: (entry: T) => U): ArrayLikeIterable<U>
filter(callback: (entry: T) => any): ArrayLikeIterable<T>
class RangeIterable<T> implements Iterable<T> {
map<U>(callback: (entry: T) => U): RangeIterable<U>
flatMap<U>(callback: (entry: T) => U[]): RangeIterable<U>
slice(start: number, end: number): RangeIterable<T>
filter(callback: (entry: T) => any): RangeIterable<T>
[Symbol.iterator]() : Iterator<T>

@@ -395,0 +401,0 @@ forEach(callback: (entry: T) => any): void

@@ -20,2 +20,3 @@ import { getAddress, orderedBinary } from './native.js';

let lastEncodedValue, bytes;
export function applyKeyHandling(store) {

@@ -30,5 +31,11 @@ if (store.encoding == 'ordered-binary') {

store.encoder.encode = function(value, mode) {
let bytes = saveKey(value, this.writeKey, false, store.maxKeySize);
if (typeof value !== 'object' && value && value === lastEncodedValue) {
// reuse the last serialized bytes
// NOTE that it is very important that nothing else calls saveKey with saveTo: false
} else {
lastEncodedValue = value;
bytes = saveKey(value, this.writeKey, false, store.maxKeySize);
}
if (bytes.end > 0 && !(REUSE_BUFFER_MODE & mode)) {
return bytes.subarray(bytes.start, bytes.end)
return bytes.subarray(bytes.start, bytes.end);
}

@@ -35,0 +42,0 @@ return bytes;

@@ -122,3 +122,4 @@ import { Compression, getAddress, arch, fs, path as pathModule, lmdbError, EventEmitter, MsgpackrEncoder, Env,

(options.remapChunks ? 0x4000000 : 0) |
(options.safeRestore ? 0x8000000 : 0);
(options.safeRestore ? 0x800 : 0) |
(options.trackMetrics ? 0x400 : 0);

@@ -125,0 +126,0 @@ let env = new Env();

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

@@ -80,3 +80,3 @@ "license": "MIT",

"dependencies": {
"msgpackr": "^1.7.0-beta1",
"msgpackr": "1.7.0",
"node-addon-api": "^4.3.0",

@@ -108,9 +108,9 @@ "node-gyp-build-optional-packages": "5.0.3",

"optionalDependencies": {
"@lmdb/lmdb-darwin-arm64": "2.6.0-beta1",
"@lmdb/lmdb-darwin-x64": "2.6.0-beta1",
"@lmdb/lmdb-linux-arm": "2.6.0-beta1",
"@lmdb/lmdb-linux-arm64": "2.6.0-beta1",
"@lmdb/lmdb-linux-x64": "2.6.0-beta1",
"@lmdb/lmdb-win32-x64": "2.6.0-beta1"
"@lmdb/lmdb-darwin-arm64": "2.6.0",
"@lmdb/lmdb-darwin-x64": "2.6.0",
"@lmdb/lmdb-linux-arm": "2.6.0",
"@lmdb/lmdb-linux-arm64": "2.6.0",
"@lmdb/lmdb-linux-x64": "2.6.0",
"@lmdb/lmdb-win32-x64": "2.6.0"
}
}

@@ -594,3 +594,3 @@ import { RangeIterable } from './util/RangeIterable.js';

},
startReadTransaction() {
useReadTransaction() {
let txn = explicitTxn || (readTxnRenewed ? readTxn : renewReadTxn(this));

@@ -650,3 +650,3 @@ txn.refCount = (txn.refCount || 0) + 1;

dbStats.root = env.stat();
dbStats.env = env.info();
Object.assign(dbStats, env.info());
dbStats.free = env.freeStat();

@@ -653,0 +653,0 @@ return dbStats;

@@ -89,3 +89,3 @@ const SKIP = {};

let isFirst = true;
let concatIterator = {
return {
next() {

@@ -107,6 +107,48 @@ let result = iterator.next();

};
return concatIterator;
};
return concatIterable;
}
flatMap(callback) {
let mappedIterable = new RangeIterable();
mappedIterable.iterate = (async) => {
let iterator = this.iterator = this.iterate(async);
let isFirst = true;
let currentSubIterator;
return {
next() {
do {
if (currentSubIterator) {
let result = currentSubIterator.next();
if (!result.done) {
return result;
}
}
let result = iterator.next();
if (result.done)
return result;
let value = callback(result.value);
if (Array.isArray(value) || value instanceof RangeIterable)
currentSubIterator = value[Symbol.iterator]();
else {
currentSubIterator = null;
return { value };
}
} while(true);
},
return() {
if (currentSubIterator)
currentSubIterator.return();
return iterator.return();
},
throw() {
if (currentSubIterator)
currentSubIterator.throw();
return iterator.throw();
}
};
};
return mappedIterable;
}
slice(start, end) {

@@ -163,1 +205,2 @@ return this.map((element, i) => {

}
RangeIterable.prototype.DONE = DONE;

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

var nextTxnCallbacks = [];
var commitPromise, flushPromise, flushResolvers = [];
var commitPromise, flushPromise, flushResolvers = [], batchFlushResolvers = [];
commitDelay = commitDelay || 0;

@@ -83,13 +83,10 @@ eventTurnBatching = eventTurnBatching === false ? false : true;

var lastQueuedResolution = uncommittedResolution;
let lastValue, valueBuffer;
function writeInstructions(flags, store, key, value, version, ifVersion) {
let writeStatus;
let targetBytes, position, encoder;
let valueSize, valueBufferStart;
let valueSize, valueBuffer, valueBufferStart;
if (flags & 2) {
// encode first in case we have to write a shared structure
encoder = store.encoder;
if (typeof value !== 'object' && value && value === lastValue && !store.compression) {
// reuse last valueBuffer
} else if (value && value['\x10binary-data\x02'])
if (value && value['\x10binary-data\x02'])
valueBuffer = value['\x10binary-data\x02'];

@@ -110,3 +107,2 @@ else if (encoder) {

throw new Error('Invalid value to put in database ' + value + ' (' + (typeof value) +'), consider using encoder');
lastValue = (writeTxn || store.compression) ? null : value; // can't reuse values from write txns because we reset the buffer
valueBufferStart = valueBuffer.start;

@@ -280,2 +276,3 @@ if (valueBufferStart > -1) // if we have buffers with start/end position

flushPromise = null;
flushResolvers = [];
queueCommitResolution(resolution);

@@ -286,4 +283,15 @@ if (!startAddress) {

}
if (!flushPromise && overlappingSync)
flushPromise = new Promise(resolve => flushResolvers.push(resolve));
if (!writtenBatchDepth && batchFlushResolvers.length > 0) {
flushResolvers.push(...batchFlushResolvers);
batchFlushResolvers = [];
}
if (!flushPromise && overlappingSync) {
flushPromise = new Promise(resolve => {
if (writtenBatchDepth) {
batchFlushResolvers.push(resolve);
} else {
flushResolvers.push(resolve);
}
});
}
if (writeStatus & WAITING_OPERATION) { // write thread is waiting

@@ -367,3 +375,2 @@ write(env.address, 0);

let resolvers = flushResolvers;
flushResolvers = [];
let start = Date.now();

@@ -402,14 +409,16 @@ env.startWriting(startAddress, (status) => {

if (committedFlushResolvers)
committedFlushResolvers.push(...resolvers)
committedFlushResolvers.push(resolvers);
else {
committedFlushResolvers = resolvers
committedFlushResolvers = [resolvers];
lastFlushTimeout = setTimeout(lastFlushCallback = () => {
lastFlushTimeout = null;
lastSync.then(() => {
let resolvers = committedFlushResolvers || [];
let resolverSets = committedFlushResolvers || [];
committedFlushResolvers = null;
lastSync = new Promise((resolve) => {
env.sync(() => {
for (let i = 0; i < resolvers.length; i++)
resolvers[i]();
for (let resolvers of resolverSets) {
for (let resolver of resolvers)
resolver();
}
resolve();

@@ -416,0 +425,0 @@ });

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