Permalink
Browse files

interface stub

  • Loading branch information...
pkrumins committed Oct 14, 2010
1 parent 7440dec commit b5cd3b14480339c38e269ebe33a391436a0e870c
Showing with 35 additions and 0 deletions.
  1. +35 −0 lib/browser.js
View
@@ -1,5 +1,40 @@
module.exports = Browser;
function Browser () {
+ if (!(this instanceof Browser)) return new Browser();
+ var self = this;
+ var actionQueue = [];
+ function newAction(f, args) {
+ actionQueue.push({ f : f, args : args });
+ }
+
+ self.get = function (url) {
+ newAction(self.get, arguments);
+ return self;
+ }
+
+ self.post = function (url, data) {
+ newAction(self.post, arguments);
+ return self;
+ }
+
+ function get (url) {
+ console.log('get ' + url);
+ }
+
+ function post (url, data) {
+ console.log('post ' + url);
+ }
+
+ self.end = function () {
+ self.get = get;
+ self.post = post;
+ (function f () {
+ var action = actionQueue.shift();
+ if (!action) return;
+ action.f.apply(self, action.args);
+ f();
+ })();
+ }
}

0 comments on commit b5cd3b1

Please sign in to comment.