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

rethinkdb

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rethinkdb - npm Package Compare versions

Comparing version 1.10.0-0 to 1.11.0-0

169

cursor.js
// Generated by CoffeeScript 1.4.0
var ArrayResult, Cursor, IterableResult, ar, aropt, err, nextCbCheck, util, varar,
var ArrayResult, Cursor, IterableResult, ar, aropt, deconstructDatum, err, mkErr, nextCbCheck, pb, setImmediate, util, varar,
__hasProp = {}.hasOwnProperty,

@@ -10,2 +10,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

pb = require('./protobuf');
ar = util.ar;

@@ -17,2 +19,12 @@

deconstructDatum = util.deconstructDatum;
mkErr = util.mkErr;
if (!(typeof setImmediate !== "undefined" && setImmediate !== null)) {
setImmediate = function(cb) {
return setTimeout(cb, 0);
};
}
IterableResult = (function() {

@@ -83,6 +95,13 @@

function Cursor(conn, token) {
Cursor.prototype.stackSize = 100;
function Cursor(conn, token, opts, root) {
this._conn = conn;
this._token = token;
this._chunks = [];
this._opts = opts;
this._root = root;
this._responses = [];
this._responseIndex = 0;
this._outstandingRequests = 1;
this._iterations = 0;
this._endFlag = false;

@@ -94,10 +113,13 @@ this._contFlag = false;

Cursor.prototype._addChunk = function(chunk) {
if (chunk.length > 0) {
return this._chunks.push(chunk);
}
};
Cursor.prototype._addData = function(chunk) {
this._addChunk(chunk);
Cursor.prototype._addResponse = function(response) {
var _this = this;
this._responses.push(response);
this._outstandingRequests -= 1;
pb.ResponseTypeSwitch(response, {
"SUCCESS_PARTIAL": function() {
return _this._endFlag = false;
}
}, function() {
return _this._endFlag = true;
});
this._contFlag = false;

@@ -108,29 +130,77 @@ this._promptNext();

Cursor.prototype._endData = function(chunk) {
this._addChunk(chunk);
this._endFlag = true;
this._contFlag = true;
this._promptNext();
return this;
Cursor.prototype._getCallback = function() {
var cb, immediateCb;
this._iterations += 1;
cb = this._cbQueue.shift();
if (this._iterations % this.stackSize === this.stackSize - 1) {
immediateCb = (function(err, row) {
return setImmediate(function() {
return cb(err, row);
});
});
return immediateCb;
} else {
return cb;
}
};
Cursor.prototype._handleRow = function() {
var cb, response, row;
response = this._responses[0];
row = deconstructDatum(response.response[this._responseIndex], this._opts);
cb = this._getCallback();
this._responseIndex += 1;
if (this._responseIndex === response.response.length) {
this._responses.shift();
this._responseIndex = 0;
}
return cb(null, row);
};
Cursor.prototype._promptNext = function() {
var cb, chunk, row;
var cb, response,
_this = this;
while (this._cbQueue[0] != null) {
if (!this.hasNext()) {
cb = this._cbQueue.shift();
cb = this._getCallback();
cb(new err.RqlDriverError("No more rows in the cursor."));
} else {
chunk = this._chunks[0];
if (!(chunk != null)) {
response = this._responses[0];
if (this._responses.length === 1) {
this._promptCont();
return;
} else {
row = chunk.shift();
cb = this._cbQueue.shift();
if (chunk[0] === void 0) {
this._chunks.shift();
if (!this._endFlag && (response.response != null) && this._responseIndex === response.response.length - 1) {
return;
}
cb(null, row);
}
pb.ResponseTypeSwitch(response, {
"SUCCESS_PARTIAL": function() {
return _this._handleRow();
},
"SUCCESS_SEQUENCE": function() {
if (response.response.length === 0) {
return _this._responses.shift();
} else {
return _this._handleRow();
}
},
"COMPILE_ERROR": function() {
_this._responses.shift();
cb = _this._getCallback();
return cb(mkErr(err.RqlCompileError, response, _this._root));
},
"CLIENT_ERROR": function() {
_this._responses.shift();
cb = _this._getCallback();
return cb(mkErr(err.RqlClientError, response, _this._root));
},
"RUNTIME_ERROR": function() {
_this._responses.shift();
cb = _this._getCallback();
return cb(mkErr(err.RqlRuntimeError, response, _this._root));
}
}, function() {
_this._responses.shift();
cb = _this._getCallback();
return cb(new err.RqlDriverError("Unknown response type for cursor"));
});
}

@@ -141,5 +211,6 @@ }

Cursor.prototype._promptCont = function() {
if (!this._contFlag) {
this._conn._continueQuery(this._token);
return this._contFlag = true;
if (!this._contFlag && !this._endFlag) {
this._contFlag = true;
this._outstandingRequests += 1;
return this._conn._continueQuery(this._token);
}

@@ -149,3 +220,3 @@ };

Cursor.prototype.hasNext = ar(function() {
return !this._endFlag || (this._chunks[0] != null);
return (this._responses[0] != null) && this._responses[0].response.length > 0;
});

@@ -161,2 +232,3 @@

if (!this._endFlag) {
this._outstandingRequests += 1;
return this._conn._endQuery(this._token);

@@ -182,3 +254,8 @@ }

ArrayResult.prototype.stackSize = 100;
ArrayResult.prototype.hasNext = ar(function() {
if (!(this.__index != null)) {
this.__index = 0;
}
return this.__index < this.length;

@@ -188,6 +265,29 @@ });

ArrayResult.prototype.next = ar(function(cb) {
var self;
nextCbCheck(cb);
return cb(null, this[this.__proto__.__index++]);
if (!(this.__index != null)) {
this.__index = 0;
}
if (this.hasNext() === true) {
self = this;
if (self.__index % this.stackSize === this.stackSize - 1) {
return setImmediate(function() {
return cb(null, self[self.__index++]);
});
} else {
return cb(null, self[self.__index++]);
}
} else {
return cb(new err.RqlDriverError("No more rows in the cursor."));
}
});
ArrayResult.prototype.toArray = ar(function(cb) {
if (this.__index != null) {
return cb(null, this.slice(this.__index, this.length));
} else {
return cb(null, this);
}
});
ArrayResult.prototype.makeIterable = function(response) {

@@ -202,3 +302,2 @@ var method, name, _ref;

}
response.__proto__.__index = 0;
return response;

@@ -217,4 +316,6 @@ };

module.exports.deconstructDatum = deconstructDatum;
module.exports.Cursor = Cursor;
module.exports.makeIterable = ArrayResult.prototype.makeIterable;

@@ -28,3 +28,7 @@ // Generated by CoffeeScript 1.4.0

this.frames = frames.slice(0);
this.message = "" + msg + " in:\n" + (RqlQueryPrinter.prototype.printQuery(term)) + "\n" + (RqlQueryPrinter.prototype.printCarrots(term, frames));
if (term != null) {
this.message = "" + msg + " in:\n" + (RqlQueryPrinter.prototype.printQuery(term)) + "\n" + (RqlQueryPrinter.prototype.printCarrots(term, frames));
} else {
this.message = "" + msg;
}
}

@@ -31,0 +35,0 @@

// Generated by CoffeeScript 1.4.0
var Connection, HttpConnection, TcpConnection, ar, aropt, cursors, deconstructDatum, err, events, net, pb, r, util, varar,
var Connection, HttpConnection, TcpConnection, ar, aropt, cursors, deconstructDatum, err, events, mkAtom, mkErr, mkSeq, net, pb, r, util, varar,
__hasProp = {}.hasOwnProperty,

@@ -27,61 +27,11 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

deconstructDatum = function(datum, opts) {
var _this = this;
return pb.DatumTypeSwitch(datum, {
"R_NULL": function() {
return null;
},
"R_BOOL": function() {
return datum.r_bool;
},
"R_NUM": function() {
return datum.r_num;
},
"R_STR": function() {
return datum.r_str;
},
"R_ARRAY": function() {
var dt, _i, _len, _ref, _results;
_ref = datum.r_array;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
dt = _ref[_i];
_results.push(deconstructDatum(dt, opts));
}
return _results;
},
"R_OBJECT": function() {
var obj, pair, _i, _len, _ref;
obj = {};
_ref = datum.r_object;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
pair = _ref[_i];
obj[pair.key] = deconstructDatum(pair.val, opts);
}
switch (obj['$reql_type$']) {
case 'TIME':
switch (opts.timeFormat) {
case 'native':
case void 0:
if (!(obj['epoch_time'] != null)) {
throw new err.RqlDriverError("psudo-type TIME " + obj + " object missing expected field 'epoch_time'.");
}
return new Date(obj['epoch_time'] * 1000);
case 'raw':
return obj;
default:
throw new err.RqlDriverError("Unknown timeFormat run option " + opts.timeFormat + ".");
}
break;
default:
return obj;
}
}
}, function() {
throw new err.RqlDriverError("Unknown Datum type");
});
};
deconstructDatum = util.deconstructDatum;
mkAtom = util.mkAtom;
mkErr = util.mkErr;
mkSeq = util.mkSeq;
Connection = (function(_super) {
var mkAtom, mkErr, mkSeq;

@@ -152,37 +102,2 @@ __extends(Connection, _super);

mkAtom = function(response, opts) {
return deconstructDatum(response.response[0], opts);
};
mkSeq = function(response, opts) {
var res, _i, _len, _ref, _results;
_ref = response.response;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
res = _ref[_i];
_results.push(deconstructDatum(res, opts));
}
return _results;
};
mkErr = function(ErrClass, response, root) {
var bt, frame, msg;
msg = mkAtom(response);
bt = (function() {
var _i, _len, _ref, _results;
_ref = response.backtrace.frames;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
frame = _ref[_i];
if (frame.type === "POS") {
_results.push(parseInt(frame.pos));
} else {
_results.push(frame.opt);
}
}
return _results;
})();
return new ErrClass(msg, root, bt);
};
Connection.prototype._delQuery = function(token) {

@@ -196,19 +111,16 @@ delete this.outstandingCallbacks[token];

Connection.prototype._processResponse = function(response) {
var cb, cursor, opts, root, token, _ref,
var cb, cursor, opts, profile, root, token, _ref,
_this = this;
token = response.token;
profile = response.profile;
if (profile != null) {
profile = deconstructDatum(profile, {});
}
if (this.outstandingCallbacks[token] != null) {
_ref = this.outstandingCallbacks[token], cb = _ref.cb, root = _ref.root, cursor = _ref.cursor, opts = _ref.opts;
if (cursor != null) {
return pb.ResponseTypeSwitch(response, {
"SUCCESS_PARTIAL": function() {
return cursor._addData(mkSeq(response, opts));
},
"SUCCESS_SEQUENCE": function() {
cursor._endData(mkSeq(response, opts));
return _this._delQuery(token);
}
}, function() {
return cb(new err.RqlDriverError("Unknown response type"));
});
cursor._addResponse(response);
if (cursor._endFlag && cursor._outstandingRequests === 0) {
return this._delQuery(token);
}
} else if (cb != null) {

@@ -233,2 +145,8 @@ return pb.ResponseTypeSwitch(response, {

}
if (profile != null) {
response = {
profile: profile,
value: response
};
}
cb(null, response);

@@ -238,10 +156,28 @@ return _this._delQuery(token);

"SUCCESS_PARTIAL": function() {
cursor = new cursors.Cursor(_this, token);
cursor = new cursors.Cursor(_this, token, opts, root);
_this.outstandingCallbacks[token].cursor = cursor;
return cb(null, cursor._addData(mkSeq(response, opts)));
if (profile != null) {
return cb(null, {
profile: profile,
value: cursor._addResponse(response)
});
} else {
return cb(null, cursor._addResponse(response));
}
},
"SUCCESS_SEQUENCE": function() {
cursor = new cursors.Cursor(_this, token);
cursor = new cursors.Cursor(_this, token, opts, root);
_this._delQuery(token);
return cb(null, cursor._endData(mkSeq(response, opts)));
if (profile != null) {
return cb(null, {
profile: profile,
value: cursor._addResponse(response)
});
} else {
return cb(null, cursor._addResponse(response));
}
},
"WAIT_COMPLETE": function() {
_this._delQuery(token);
return cb(null, null);
}

@@ -257,6 +193,64 @@ }, function() {

Connection.prototype.close = ar(function() {
return this.open = false;
Connection.prototype.close = varar(0, 2, function(optsOrCallback, callback) {
var cb, key, noreplyWait, opts, wrappedCb,
_this = this;
if (callback != null) {
opts = optsOrCallback;
if (Object.prototype.toString.call(opts) !== '[object Object]') {
throw new err.RqlDriverError("First argument to two-argument `close` must be an object.");
}
cb = callback;
} else if (Object.prototype.toString.call(optsOrCallback) === '[object Object]') {
opts = optsOrCallback;
cb = null;
} else {
opts = {};
cb = optsOrCallback;
}
for (key in opts) {
if (!__hasProp.call(opts, key)) continue;
if (key !== 'noreplyWait') {
throw new err.RqlDriverError("First argument to two-argument `close` must be { noreplyWait: <bool> }.");
}
}
if (!(!(cb != null) || typeof cb === 'function')) {
throw new err.RqlDriverError("Final argument to `close` must be a callback function or object.");
}
wrappedCb = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
_this.open = false;
if (cb != null) {
return cb.apply(null, args);
}
};
noreplyWait = ((!(opts.noreplyWait != null)) || opts.noreplyWait) && this.open;
if (noreplyWait) {
return this.noreplyWait(wrappedCb);
} else {
return wrappedCb();
}
});
Connection.prototype.noreplyWait = ar(function(callback) {
var query, token;
if (typeof callback !== 'function') {
throw new err.RqlDriverError("First argument to noreplyWait must be a callback function.");
}
if (!this.open) {
callback(new err.RqlDriverError("Connection is closed."));
return;
}
token = this.nextToken++;
query = {};
query.type = "NOREPLY_WAIT";
query.token = token;
this.outstandingCallbacks[token] = {
cb: callback,
root: null,
opts: null
};
return this._sendQuery(query);
});
Connection.prototype.cancel = ar(function() {

@@ -266,12 +260,30 @@ return this.outstandingCallbacks = {};

Connection.prototype.reconnect = ar(function(callback) {
var cb,
Connection.prototype.reconnect = varar(1, 2, function(optsOrCallback, callback) {
var cb, closeCb, opts,
_this = this;
cb = function() {
return _this.constructor.call(_this, {
host: _this.host,
port: _this.port
}, callback);
if (callback != null) {
opts = optsOrCallback;
cb = callback;
} else {
opts = {};
cb = optsOrCallback;
}
if (typeof cb !== 'function') {
throw new err.RqlDriverError("Final argument to `reconnect` must be a callback function.");
}
closeCb = function(err) {
var constructCb;
if (err != null) {
return cb(err);
} else {
constructCb = function() {
return _this.constructor.call(_this, {
host: _this.host,
port: _this.port
}, cb);
};
return setTimeout(constructCb, 0);
}
};
return setTimeout(cb, 0);
return this.close(opts, closeCb);
});

@@ -316,2 +328,9 @@

}
if (opts.profile != null) {
pair = {
key: 'profile',
val: r.expr(!!opts.profile).build()
};
query.global_optargs.push(pair);
}
if ((!(opts.noreply != null)) || !opts.noreply) {

@@ -340,4 +359,3 @@ this.outstandingCallbacks[token] = {

Connection.prototype._endQuery = function(token) {
var query,
_this = this;
var query;
query = {

@@ -347,9 +365,2 @@ type: "STOP",

};
this.outstandingCallbacks[token] = {
cb: (function() {
return _this._delQuery(token);
}),
root: null,
opts: {}
};
return this._sendQuery(query);

@@ -360,2 +371,3 @@ };

var data, i, totalBuf;
query.accepts_r_json = true;
data = pb.SerializeQuery(query);

@@ -392,3 +404,5 @@ totalBuf = new Buffer(data.length + 4);

if (this.rawSocket != null) {
this.close();
this.close({
noreplyWait: false
});
}

@@ -445,10 +459,34 @@ this.rawSocket = net.connect(this.port, this.host);

_this.open = false;
return _this.emit('close');
return _this.emit('close', {
noreplyWait: false
});
});
}
TcpConnection.prototype.close = function() {
TcpConnection.__super__.close.call(this);
return this.rawSocket.end();
};
TcpConnection.prototype.close = varar(0, 2, function(optsOrCallback, callback) {
var cb, opts, wrappedCb,
_this = this;
if (callback != null) {
opts = optsOrCallback;
cb = callback;
} else if (Object.prototype.toString.call(optsOrCallback) === '[object Object]') {
opts = optsOrCallback;
cb = null;
} else {
opts = {};
cb = optsOrCallback;
}
if (!(!(cb != null) || typeof cb === 'function')) {
throw new err.RqlDriverError("Final argument to `close` must be a callback function or object.");
}
wrappedCb = function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
_this.rawSocket.end();
if (cb != null) {
return cb.apply(null, args);
}
};
return TcpConnection.__super__.close.call(this, opts, wrappedCb);
});

@@ -551,3 +589,3 @@ TcpConnection.prototype.cancel = function() {

module.exports.connect = ar(function(host, callback) {
if (!(typeof host === 'string' || typeof host === 'object')) {
if (!(typeof host === 'string' || Object.prototype.toString.call(host) === '[object Object]')) {
throw new err.RqlDriverError("First argument to `connect` must be a string giving the " + "host to `connect` to or an object giving `host` and `port`.");

@@ -554,0 +592,0 @@ }

{ "name" : "rethinkdb"
, "version" : "1.10.0-0"
, "version" : "1.11.0-0"
, "main" : "rethinkdb"

@@ -18,4 +18,3 @@ , "description" : "This package provides the JavaScript driver library for the RethinkDB database server for use either from node or your web-browser."

, "dependencies" : { "protobufjs": ">= 1.1.4" }
, "optionalDependencies" : { "node-protobuf": ">= 1.0.0" }
, "browser": { "./native-protobuf": false }
}

@@ -60,2 +60,11 @@ module.exports = require("protobufjs").newBuilder().import({

{
"rule": "optional",
"type": "bool",
"name": "accepts_r_json",
"id": 5,
"options": {
"default": "false"
}
},
{
"rule": "repeated",

@@ -83,2 +92,6 @@ "type": "AssocPair",

"id": 3
},
{
"name": "NOREPLY_WAIT",
"id": 4
}

@@ -204,2 +217,9 @@ ],

"options": {}
},
{
"rule": "optional",
"type": "Datum",
"name": "profile",
"id": 5,
"options": {}
}

@@ -224,2 +244,6 @@ ],

{
"name": "WAIT_COMPLETE",
"id": 4
},
{
"name": "CLIENT_ERROR",

@@ -316,2 +340,6 @@ "id": 16

"id": 6
},
{
"name": "R_JSON",
"id": 7
}

@@ -685,2 +713,6 @@ ],

{
"name": "SYNC",
"id": 138
},
{
"name": "INDEX_CREATE",

@@ -698,2 +730,10 @@ "id": 75

{
"name": "INDEX_STATUS",
"id": 139
},
{
"name": "INDEX_WAIT",
"id": 140
},
{
"name": "FUNCALL",

@@ -700,0 +740,0 @@ "id": 64

// Generated by CoffeeScript 1.4.0
var err,
var deconstructDatum, err, mkAtom, mkErr, mkSeq, pb,
__slice = [].slice;

@@ -7,2 +7,4 @@

pb = require('./protobuf');
module.exports.ar = function(fun) {

@@ -54,9 +56,112 @@ return function() {

module.exports.toArrayBuffer = function(node_buffer) {
var arr, byte, i, _i, _len;
var arr, i, value, _i, _len;
arr = new Uint8Array(new ArrayBuffer(node_buffer.length));
for (i = _i = 0, _len = node_buffer.length; _i < _len; i = ++_i) {
byte = node_buffer[i];
arr[i] = byte;
value = node_buffer[i];
arr[i] = value;
}
return arr.buffer;
};
deconstructDatum = function(datum, opts) {
var _this = this;
return pb.DatumTypeSwitch(datum, {
"R_JSON": function() {
return JSON.parse(datum.r_str);
},
"R_NULL": function() {
return null;
},
"R_BOOL": function() {
return datum.r_bool;
},
"R_NUM": function() {
return datum.r_num;
},
"R_STR": function() {
return datum.r_str;
},
"R_ARRAY": function() {
var dt, _i, _len, _ref, _results;
_ref = datum.r_array;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
dt = _ref[_i];
_results.push(deconstructDatum(dt, opts));
}
return _results;
},
"R_OBJECT": function() {
var obj, pair, _i, _len, _ref;
obj = {};
_ref = datum.r_object;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
pair = _ref[_i];
obj[pair.key] = deconstructDatum(pair.val, opts);
}
switch (obj['$reql_type$']) {
case 'TIME':
switch (opts.timeFormat) {
case 'native':
case void 0:
if (!(obj['epoch_time'] != null)) {
throw new err.RqlDriverError("pseudo-type TIME " + obj + " object missing expected field 'epoch_time'.");
}
return new Date(obj['epoch_time'] * 1000);
case 'raw':
return obj;
default:
throw new err.RqlDriverError("Unknown timeFormat run option " + opts.timeFormat + ".");
}
break;
default:
return obj;
}
}
}, function() {
throw new err.RqlDriverError("Unknown Datum type");
});
};
mkAtom = function(response, opts) {
return deconstructDatum(response.response[0], opts);
};
mkSeq = function(response, opts) {
var res, _i, _len, _ref, _results;
_ref = response.response;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
res = _ref[_i];
_results.push(deconstructDatum(res, opts));
}
return _results;
};
mkErr = function(ErrClass, response, root) {
var bt, frame, msg;
msg = mkAtom(response);
bt = (function() {
var _i, _len, _ref, _results;
_ref = response.backtrace.frames;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
frame = _ref[_i];
if (frame.type === "POS") {
_results.push(parseInt(frame.pos));
} else {
_results.push(frame.opt);
}
}
return _results;
})();
return new ErrClass(msg, root, bt);
};
module.exports.deconstructDatum = deconstructDatum;
module.exports.mkAtom = mkAtom;
module.exports.mkSeq = mkSeq;
module.exports.mkErr = mkErr;

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

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