From: miker Date: Wed, 3 Feb 2010 15:15:30 +0000 (+0000) Subject: add non-destructive methods for grabbing first and last responses on the response... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fcfacdf91db3c2a92b6419a57e421a9d04d01af5;p=opensrf%2Fbjwebb.git add non-destructive methods for grabbing first and last responses on the response queue git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1918 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/javascript/opensrf.js b/src/javascript/opensrf.js index 5675cbd..7718d92 100644 --- a/src/javascript/opensrf.js +++ b/src/javascript/opensrf.js @@ -195,6 +195,21 @@ OpenSRF.Request = function(session, reqid, args) { this.complete = false; } +OpenSRF.Request.prototype.peek_last = function(timeout) { + if(this.response_queue.length > 0) { + var x = this.response_queue.pop(); + this.response_queue.push(x); + return x; + } + return null; +} + +OpenSRF.Request.prototype.peek = function(timeout) { + if(this.response_queue.length > 0) + return this.response_queue[0]; + return null; +} + OpenSRF.Request.prototype.recv = function(timeout) { if(this.response_queue.length > 0) return this.response_queue.shift();