Comparing version 2.1.1 to 2.2.0
102
cursor.js
@@ -54,2 +54,3 @@ // Generated by CoffeeScript 1.7.0 | ||
this.each = this._each; | ||
this.eachAsync = this._eachAsync; | ||
} | ||
@@ -71,3 +72,3 @@ | ||
case protoResponseType.COMPILE_ERROR: | ||
this._closeCb(mkErr(err.ReqlCompileError, response, this._root)); | ||
this._closeCb(mkErr(err.ReqlServerCompileError, response, this._root)); | ||
break; | ||
@@ -157,3 +158,3 @@ case protoResponseType.CLIENT_ERROR: | ||
cb = this._getCallback(); | ||
cb(mkErr(err.ReqlCompileError, response, this._root)); | ||
cb(mkErr(err.ReqlServerCompileError, response, this._root)); | ||
break; | ||
@@ -193,3 +194,6 @@ case protoResponseType.CLIENT_ERROR: | ||
IterableResult.prototype._next = varar(0, 1, function(cb) { | ||
var fn, p; | ||
var fn; | ||
if ((cb != null) && typeof cb !== "function") { | ||
throw new err.ReqlDriverError("First argument to `next` must be a function or undefined."); | ||
} | ||
fn = (function(_this) { | ||
@@ -201,19 +205,3 @@ return function(cb) { | ||
})(this); | ||
if (typeof cb === "function") { | ||
return fn(cb); | ||
} else if (cb === void 0) { | ||
p = new Promise(function(resolve, reject) { | ||
cb = function(err, result) { | ||
if (err) { | ||
return reject(err); | ||
} else { | ||
return resolve(result); | ||
} | ||
}; | ||
return fn(cb); | ||
}); | ||
return p; | ||
} else { | ||
throw new err.ReqlDriverError("First argument to `next` must be a function or undefined."); | ||
} | ||
return Promise.fromNode(fn).nodeify(cb); | ||
}); | ||
@@ -256,3 +244,3 @@ | ||
IterableResult.prototype._each = varar(1, 2, function(cb, onFinished) { | ||
var nextCb, self, stopFlag; | ||
var nextCb, self; | ||
if (typeof cb !== 'function') { | ||
@@ -264,21 +252,15 @@ throw new err.ReqlDriverError("First argument to each must be a function."); | ||
} | ||
stopFlag = false; | ||
self = this; | ||
nextCb = (function(_this) { | ||
return function(err, data) { | ||
if (stopFlag !== true) { | ||
if (err != null) { | ||
if (err.message === 'No more rows in the cursor.') { | ||
if (onFinished != null) { | ||
return onFinished(); | ||
} | ||
} else { | ||
return cb(err); | ||
} | ||
if (err != null) { | ||
if (err.message === 'No more rows in the cursor.') { | ||
return typeof onFinished === "function" ? onFinished() : void 0; | ||
} else { | ||
stopFlag = cb(null, data) === false; | ||
return _this._next(nextCb); | ||
return cb(err); | ||
} | ||
} else if (onFinished != null) { | ||
return onFinished(); | ||
} else if (cb(null, data) !== false) { | ||
return _this._next(nextCb); | ||
} else { | ||
return typeof onFinished === "function" ? onFinished() : void 0; | ||
} | ||
@@ -290,37 +272,27 @@ }; | ||
IterableResult.prototype.toArray = varar(0, 1, function(cb) { | ||
var fn; | ||
fn = (function(_this) { | ||
return function(cb) { | ||
var arr, eachCb, onFinish; | ||
arr = []; | ||
eachCb = function(err, row) { | ||
if (err != null) { | ||
return cb(err); | ||
} else { | ||
return arr.push(row); | ||
IterableResult.prototype._eachAsync = function(cb) { | ||
var nextCb; | ||
if (typeof cb !== 'function') { | ||
throw new err.ReqlDriverCompileError("First argument to eachAsync must be a function."); | ||
} | ||
nextCb = (function(_this) { | ||
return function() { | ||
return _this._next().then(cb).then(nextCb)["catch"](function(err) { | ||
if ((err != null ? err.message : void 0) === 'No more rows in the cursor.') { | ||
return; | ||
} | ||
}; | ||
onFinish = function(err, ar) { | ||
return cb(null, arr); | ||
}; | ||
return _this.each(eachCb, onFinish); | ||
throw err; | ||
}); | ||
}; | ||
})(this); | ||
return nextCb(); | ||
}; | ||
IterableResult.prototype.toArray = varar(0, 1, function(cb) { | ||
var results; | ||
if ((cb != null) && typeof cb !== 'function') { | ||
throw new err.ReqlDriverError("First argument to `toArray` must be a function or undefined."); | ||
throw new err.ReqlDriverCompileError("First argument to `toArray` must be a function or undefined."); | ||
} | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
var toArrayCb; | ||
toArrayCb = function(err, result) { | ||
if (err != null) { | ||
return reject(err); | ||
} else { | ||
return resolve(result); | ||
} | ||
}; | ||
return fn(toArrayCb); | ||
}; | ||
})(this)).nodeify(cb); | ||
results = []; | ||
return this.eachAsync(results.push.bind(results))["return"](results).nodeify(cb); | ||
}); | ||
@@ -327,0 +299,0 @@ |
// Generated by CoffeeScript 1.7.0 | ||
var ReqlAuthError, ReqlAvailabilityError, ReqlCompileError, ReqlDriverError, ReqlError, ReqlInternalError, ReqlNonExistenceError, ReqlOpFailedError, ReqlOpIndeterminateError, ReqlQueryLogicError, ReqlQueryPrinter, ReqlResourceLimitError, ReqlRuntimeError, ReqlTimeoutError, ReqlUserError, | ||
var ReqlAuthError, ReqlAvailabilityError, ReqlCompileError, ReqlDriverCompileError, ReqlDriverError, ReqlError, ReqlInternalError, ReqlNonExistenceError, ReqlOpFailedError, ReqlOpIndeterminateError, ReqlQueryLogicError, ReqlQueryPrinter, ReqlResourceLimitError, ReqlRuntimeError, ReqlServerCompileError, ReqlTimeoutError, ReqlUserError, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -33,2 +33,24 @@ __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; }; | ||
ReqlDriverCompileError = (function(_super) { | ||
__extends(ReqlDriverCompileError, _super); | ||
function ReqlDriverCompileError() { | ||
return ReqlDriverCompileError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlDriverCompileError; | ||
})(ReqlCompileError); | ||
ReqlServerCompileError = (function(_super) { | ||
__extends(ReqlServerCompileError, _super); | ||
function ReqlServerCompileError() { | ||
return ReqlServerCompileError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlServerCompileError; | ||
})(ReqlCompileError); | ||
ReqlDriverError = (function(_super) { | ||
@@ -290,2 +312,4 @@ __extends(ReqlDriverError, _super); | ||
RqlCompileError: ReqlCompileError, | ||
ReqlServerCompileError: ReqlServerCompileError, | ||
ReqlDriverCompileError: ReqlDriverCompileError, | ||
RqlClientError: ReqlDriverError, | ||
@@ -292,0 +316,0 @@ ReqlRuntimeError: ReqlRuntimeError, |
37
net.js
@@ -141,3 +141,3 @@ // Generated by CoffeeScript 1.7.0 | ||
case protoResponseType.COMPILE_ERROR: | ||
cb(mkErr(err.ReqlCompileError, response, root)); | ||
cb(mkErr(err.ReqlServerCompileError, response, root)); | ||
return this._delQuery(token); | ||
@@ -219,2 +219,6 @@ case protoResponseType.CLIENT_ERROR: | ||
return cb(null, null); | ||
case protoResponseType.SERVER_INFO: | ||
this._delQuery(token); | ||
response = mkAtom(response, opts); | ||
return cb(null, response); | ||
default: | ||
@@ -311,2 +315,33 @@ return cb(new err.ReqlDriverError("Unknown response type")); | ||
Connection.prototype.server = varar(0, 1, function(callback) { | ||
var query, token; | ||
if (!this.open) { | ||
return new Promise(function(resolve, reject) { | ||
return reject(new err.ReqlDriverError("Connection is closed.")); | ||
}).nodeify(callback); | ||
} | ||
token = this.nextToken++; | ||
query = {}; | ||
query.type = protoQueryType.SERVER_INFO; | ||
query.token = token; | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
var wrappedCb; | ||
wrappedCb = function(err, result) { | ||
if (err) { | ||
return reject(err); | ||
} else { | ||
return resolve(result); | ||
} | ||
}; | ||
_this.outstandingCallbacks[token] = { | ||
cb: wrappedCb, | ||
root: null, | ||
opts: null | ||
}; | ||
return _this._sendQuery(query); | ||
}; | ||
})(this)).nodeify(callback); | ||
}); | ||
Connection.prototype.cancel = ar(function() { | ||
@@ -313,0 +348,0 @@ var key, response, value, _ref; |
{ "name" : "rethinkdb" | ||
, "version" : "2.1.1" | ||
, "version" : "2.2.0" | ||
, "main" : "rethinkdb" | ||
@@ -4,0 +4,0 @@ , "description" : "This package provides the JavaScript driver library for the RethinkDB database server for use either from node or your web-browser." |
@@ -24,3 +24,4 @@ // DO NOT EDIT | ||
STOP: 3, | ||
NOREPLY_WAIT: 4 | ||
NOREPLY_WAIT: 4, | ||
SERVER_INFO: 5 | ||
}, | ||
@@ -46,2 +47,3 @@ | ||
WAIT_COMPLETE: 4, | ||
SERVER_INFO: 5, | ||
CLIENT_ERROR: 16, | ||
@@ -129,2 +131,3 @@ COMPILE_ERROR: 17, | ||
KEYS: 94, | ||
VALUES: 186, | ||
OBJECT: 143, | ||
@@ -131,0 +134,0 @@ HAS_FIELDS: 32, |
@@ -14,2 +14,4 @@ // Generated by CoffeeScript 1.7.0 | ||
rethinkdb._bluebird = require('bluebird'); | ||
module.exports = rethinkdb; |
12
util.js
@@ -24,3 +24,3 @@ // Generated by CoffeeScript 1.7.0 | ||
if (args.length !== fun.length) { | ||
throw new err.ReqlDriverError("Expected " + fun.length + " argument" + (plural(fun.length)) + " but found " + args.length + "."); | ||
throw new err.ReqlDriverCompileError("Expected " + fun.length + " argument" + (plural(fun.length)) + " but found " + args.length + "."); | ||
} | ||
@@ -37,8 +37,8 @@ return fun.apply(this, args); | ||
if ((min != null) && (max == null)) { | ||
throw new err.ReqlDriverError("Expected " + min + " or more arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverCompileError("Expected " + min + " or more arguments but found " + args.length + "."); | ||
} | ||
if ((max != null) && (min == null)) { | ||
throw new err.ReqlDriverError("Expected " + max + " or fewer arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverCompileError("Expected " + max + " or fewer arguments but found " + args.length + "."); | ||
} | ||
throw new err.ReqlDriverError("Expected between " + min + " and " + max + " arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverCompileError("Expected between " + min + " and " + max + " arguments but found " + args.length + "."); | ||
} | ||
@@ -61,5 +61,5 @@ return fun.apply(this, args); | ||
if (expectedPosArgs !== 1) { | ||
throw new err.ReqlDriverError("Expected " + expectedPosArgs + " arguments (not including options) but found " + numPosArgs + "."); | ||
throw new err.ReqlDriverCompileError("Expected " + expectedPosArgs + " arguments (not including options) but found " + numPosArgs + "."); | ||
} else { | ||
throw new err.ReqlDriverError("Expected " + expectedPosArgs + " argument (not including options) but found " + numPosArgs + "."); | ||
throw new err.ReqlDriverCompileError("Expected " + expectedPosArgs + " argument (not including options) but found " + numPosArgs + "."); | ||
} | ||
@@ -66,0 +66,0 @@ } |
Sorry, the diff of this file is too big to display
193073
5572