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

rethinkdbdash

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rethinkdbdash - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

1

lib/connection.js

@@ -28,3 +28,2 @@ var net = require('net');

if (options.db) this.db = options.db; // Pass to each query
if (options.max_batch_rows) this.max_batch_rows = options.max_batch_rows; // For testing only

@@ -31,0 +30,0 @@ this.token = 1;

43

lib/cursor.js

@@ -25,2 +25,3 @@ var Promise = require('bluebird');

this.each = this._each;
this.eachAsync = this._eachAsync;
this.next = this._next;

@@ -248,2 +249,41 @@ }

}
Cursor.prototype._eachAsync = function(callback, onFinish) {
if (this._closed === true) {
return callback(new Err.ReqlDriverError('You cannot retrieve data from a cursor that is closed').setOperational());
}
var self = this;
var reject = function(err) {
if (err.message === 'No more rows in the '+self._type.toLowerCase()+'.') {
if (typeof onFinish === 'function') {
onFinish();
}
}
else {
callback(err);
}
}
var resolve = function(data) {
return callback(null, data).then(function() {
if (self._closed === false) {
return self._next().then(resolve).error(function(error) {
if ((error.message !== 'You cannot retrieve data from a cursor that is closed.') &&
(error.message.match(/You cannot call `next` on a closed/) === null)) {
reject(error);
}
});
}
return null;
});
}
self._next().then(resolve).error(function(error) {
// We can silence error when the cursor is closed as this
if ((error.message !== 'You cannot retrieve data from a cursor that is closed.') &&
(error.message.match(/You cannot call `next` on a closed/) === null)) {
reject(error);
}
});
}
Cursor.prototype._makeEmitter = function() {

@@ -256,2 +296,5 @@ this.next = function() {

}
this.eachAsync = function() {
throw new Err.ReqlDriverError('You cannot call `eachAsync` once you have bound listeners on the '+this._type)
}
this.toArray = function() {

@@ -258,0 +301,0 @@ throw new Err.ReqlDriverError('You cannot call `toArray` once you have bound listeners on the '+this._type)

{
"name": "rethinkdbdash",
"version": "2.2.1",
"version": "2.2.2",
"description": "A Node.js driver for RethinkDB with promises and a connection pool",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -104,2 +104,37 @@ var config = require('./config.js');

})
It('`eachAsync` should work', function* (done) {
try {
cursor = yield r.db(dbName).table(tableName).run({cursor: true});
assert(cursor);
var history = [];
var count = 0;
var promisesWait = 0;
cursor.eachAsync(function(err, result) {
history.push(count);
count++;
return new Promise(function(resolve, reject) {
setTimeout(function() {
history.push(promisesWait);
promisesWait--;
if (count === numDocs) {
var expected = [];
for(var i=0; i<numDocs; i++) {
expected.push(i);
expected.push(-1*i);
}
assert.deepEqual(history, expected)
done();
}
resolve();
}, 1);
});
})
}
catch(e) {
done(e);
}
})
It('`each` should work - onFinish - reach end', function* (done) {

@@ -281,6 +316,6 @@ try {

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
cursor = yield r.db(dbName).table(tableName).run(connection, {cursor: true});
cursor = yield r.db(dbName).table(tableName).run(connection, {cursor: true, maxBatchRows: 1});

@@ -298,6 +333,6 @@ assert(cursor);

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
result = yield r.db(dbName).table(tableName).run(connection);
result = yield r.db(dbName).table(tableName).run(connection, {maxBatchRows: 1});
assert(result.length > 0);

@@ -313,6 +348,6 @@ done();

try {
var connection = yield r.connect({max_batch_rows: 10, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
cursor = yield r.db(dbName).table(tableName).run(connection, {cursor: true});
cursor = yield r.db(dbName).table(tableName).run(connection, {cursor: true, maxBatchRows: 1});

@@ -344,3 +379,3 @@ assert(cursor);

try {
var connection = yield r.connect({max_batch_rows: 10, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);

@@ -351,3 +386,3 @@

.map(r.row("val").add(1))
.run(connection, {cursor: true});
.run(connection, {cursor: true, maxBatchRows: 10});

@@ -354,0 +389,0 @@ assert(cursor);

@@ -150,6 +150,6 @@ var config = require('./config.js');

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true, maxBatchRows: 1});
assert(stream);

@@ -169,6 +169,6 @@ assert(stream instanceof Readable);

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true, maxBatchRows: 1});
var count = 0;

@@ -189,6 +189,6 @@ stream.on('data', function() {

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true, maxBatchRows: 1});
stream.once('readable', function() {

@@ -216,6 +216,6 @@ var doc = stream.read();

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true, maxBatchRows: 1});
var count = 0;

@@ -241,6 +241,6 @@ stream.on('data', function() {

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).limit(10).union([null]).union(r.db(dbName).table(tableName).limit(10)).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).limit(10).union([null]).union(r.db(dbName).table(tableName).limit(10)).run(connection, {stream: true, maxBatchRows: 1});
stream.once('readable', function() {

@@ -266,6 +266,6 @@ var count = 0;

try {
var connection = yield r.connect({max_batch_rows: 1, host: config.host, port: config.port, authKey: config.authKey});
var connection = yield r.connect({host: config.host, port: config.port, authKey: config.authKey});
assert(connection);
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true});
stream = yield r.db(dbName).table(tableName).run(connection, {stream: true, maxBatchRows: 1});
stream.once('readable', function() {

@@ -272,0 +272,0 @@ var doc = stream.read();

Sorry, the diff of this file is too big to display

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