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

node-lmdb

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-lmdb - npm Package Compare versions

Comparing version 0.4.13 to 0.5.0

crash.js

4

examples/10-binkeycursors.js

@@ -44,3 +44,3 @@

// Create cursor
var cursor = new lmdb.Cursor(txn, dbi, true);
var cursor = new lmdb.Cursor(txn, dbi, { keyIsBuffer: true });

@@ -97,3 +97,3 @@ console.log("first (expected a)");

for (var found = cursor.goToFirst(); found; found = cursor.goToNext()) {
for (var found = cursor.goToFirst(); found !== null; found = cursor.goToNext()) {
console.log("-----> key:", found);

@@ -100,0 +100,0 @@ }

@@ -96,3 +96,3 @@

for (var found = cursor.goToFirst(); found; found = cursor.goToNext()) {
for (var found = cursor.goToFirst(); found !== null; found = cursor.goToNext()) {
console.log("-----> key:", found);

@@ -99,0 +99,0 @@ }

@@ -97,3 +97,3 @@

for (var found = (cursor.goToRange(key) === key); found; found = cursor.goToNextDup()) {
for (var found = (cursor.goToRange(key) === key); found !== null; found = cursor.goToNextDup()) {
cursor.getCurrentNumber(function(key, data) {

@@ -100,0 +100,0 @@ // do something with data

@@ -127,3 +127,3 @@ var lmdb = require('..');

for (var found = cursor1.goToFirst(); found; found = cursor1.goToNext()) {
for (var found = cursor1.goToFirst(); found !== null; found = cursor1.goToNext()) {
console.log("-----> key:", found);

@@ -135,3 +135,3 @@ }

for (var found = cursor2.goToFirst(); found; found = cursor2.goToNext()) {
for (var found = cursor2.goToFirst(); found !== null; found = cursor2.goToNext()) {
console.log("-----> key:", found);

@@ -138,0 +138,0 @@ }

@@ -96,3 +96,3 @@

// Go the the first occourence of `str` and iterate from there
for (var found = cursor.goToRange(str); found; found = cursor.goToNext()) {
for (var found = cursor.goToRange(str); found !== null; found = cursor.goToNext()) {
// Stop the loop if the current key is no longer what we're looking for

@@ -99,0 +99,0 @@ if (found !== str)

@@ -19,3 +19,3 @@ {

"repository": "https://github.com/Venemo/node-lmdb",
"version": "0.4.13",
"version": "0.5.0",
"main": "./index.js",

@@ -22,0 +22,0 @@ "scripts": {

@@ -29,5 +29,5 @@ node-lmdb

* Tested and works on Linux (author uses Fedora 20)
* Tested and works on Mac OS X - see https://github.com/Venemo/node-lmdb/issues/3
* **Not yet tested** on Windows - see https://github.com/Venemo/node-lmdb/issues/2
* Tested and works on Linux (author uses Fedora)
* Tested and works on Mac OS X
* Tested and works on Windows

@@ -130,2 +130,16 @@ ### License info

Example iteration over a database with a `Cursor`:
```javascript
var cursor = new lmdb.Cursor(txn, dbi);
for (var found = cursor.goToFirst(); found !== null; found = cursor.goToNext()) {
// Here 'found' contains the key, and you can get the data with eg. getCurrentString/getCurrentBinary etc.
// ...
}
```
The cursor `goTo` methods (`goToFirst`, `goToNext`, etc.) will return the current key. When an item is not found, `null` is returned.
Beware that the key itself could be a *falsy* JavaScript value, so you need to explicitly check against `null` with the `!==` operator in your loops.
### Data Types in node-lmdb

@@ -132,0 +146,0 @@

@@ -9,2 +9,3 @@ 'use strict';

var lmdb = require('..');
const MAX_DB_SIZE = 256 * 1024 * 1024;

@@ -19,3 +20,3 @@ if (cluster.isMaster) {

maxDbs: 10,
mapSize: 4096 * 4096 * 16,
mapSize: MAX_DB_SIZE,
maxReaders: 126

@@ -77,3 +78,3 @@ });

maxDbs: 10,
mapSize: 4096 * 4096,
mapSize: MAX_DB_SIZE,
maxReaders: 126,

@@ -80,0 +81,0 @@ readOnly: true

@@ -11,2 +11,3 @@ 'use strict';

var lmdb = require('..');
const MAX_DB_SIZE = 256 * 1024 * 1024;

@@ -53,2 +54,5 @@ describe('Node.js LMDB Bindings', function() {

env.sync.should.be.a('function');
env.resize.should.be.a('function');
env.stat.should.be.a('function');
env.info.should.be.a('function');
env.close();

@@ -65,3 +69,3 @@ });

maxReaders: 422,
mapSize: 100 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -96,2 +100,13 @@ });

});
it('env.openDbi should throw an error when invalid parameters are passed', function() {
chai.assert.throw(function () {
env.openDbi();
});
chai.assert.throw(function () {
env.openDbi(null);
});
chai.assert.throw(function () {
env.openDbi(1);
});
});
it('will open a database, begin a transaction and get/put/delete string data containing zeros', function() {

@@ -185,5 +200,47 @@ var dbi = env.openDbi({

should.equal(info.mapSize, 100 * 1024 * 1024);
should.equal(info.mapSize, MAX_DB_SIZE);
should.equal(info.maxReaders, 422);
});
it('will check for open transactions before resizing the mapSize', function() {
var dbi = env.openDbi({
name: 'mydb1',
create: true
});
var info = env.info();
should.equal(info.mapSize, MAX_DB_SIZE);
// Open write transaction
var txn = env.beginTxn();
try {
env.resize(info.mapSize * 2);
} catch (err) {
err.should.be.an.instanceof(Error);
}
txn.abort();
info = env.info();
should.equal(info.mapSize, MAX_DB_SIZE);
// Open readOnly transaction
txn = env.beginTxn({ readOnly: true });
try {
env.resize(info.mapSize * 2);
} catch (err) {
err.should.be.an.instanceof(Error);
}
txn.abort();
info = env.info();
should.equal(info.mapSize, MAX_DB_SIZE);
dbi.close();
});
it('will resize the mapSize', function() {
var dbi = env.openDbi({
name: 'mydb1',
create: true
});
var info = env.info();
should.equal(info.mapSize, MAX_DB_SIZE);
env.resize(info.mapSize * 2);
info = env.info();
should.equal(info.mapSize, 2 * MAX_DB_SIZE);
dbi.close();
});
it('will get statistics about an environment', function() {

@@ -386,3 +443,3 @@ var stat = env.stat();

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -474,3 +531,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -589,3 +646,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -673,3 +730,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -789,3 +846,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -863,3 +920,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -939,3 +996,3 @@ dbi = env.openDbi({

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -1040,3 +1097,3 @@ });

maxDbs: 10,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -1092,3 +1149,3 @@ dbi = env.openDbi({

maxDbs: 12,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -1131,3 +1188,3 @@ var dbi = env.openDbi({

maxDbs: 12,
mapSize: 64 * 1024 * 1024
mapSize: MAX_DB_SIZE
});

@@ -1134,0 +1191,0 @@ dbi = env.openDbi({

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