add non-destructive methods for grabbing first and last responses on the response...
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 3 Feb 2010 15:15:30 +0000 (15:15 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 3 Feb 2010 15:15:30 +0000 (15:15 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1918 9efc2488-bf62-4759-914b-345cdb29e865

src/javascript/opensrf.js

index 5675cbd..7718d92 100644 (file)
@@ -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();