Skip to content

Commit

Permalink
add total results reder
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Aug 18, 2014
1 parent c151dc6 commit 001db8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ Object.defineProperties(Message.prototype, {
}
},

total: {
get: function () {
if (!this.res) return undefined;
return parseInt(this.headers['total-results'], 10);
}
},

/**
* The response's HTTP status code.
*
Expand Down Expand Up @@ -147,6 +154,10 @@ Object.defineProperties(Message.prototype, {

// --- Message Prototype Methods ---

Message.prototype.isList = function () {
return this.type === 'json' && Array.isArray(this.data);
};

/**
* Resets the message state; use if you need to reuse
* a message object.
Expand Down Expand Up @@ -359,7 +370,7 @@ function reader(obj, name, value) {
var descriptor = { configurable: true };

if (typeof value === 'function') {
descriptor.get = value;
descriptor.get = value;
} else {
descriptor.value = value;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/zotero.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var Message = require('./message');
* as easy as possible to bootstrap a Zotero client application in Node.js;
* it comes with hardly any runtime dependencies and provides three simple
* abstractions to interact with Zotero: `Client`, `Library`, and `Message`.
*
*
* Clients handle the HTTPS connection to a Zotero data server, observing
* any rate-limiting directives issued by the server; you can configure
* settings (like API versions, default headers etc.) for each Client.
Expand Down

0 comments on commit 001db8e

Please sign in to comment.