Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created May 17, 2012 23:05
Show Gist options
  • Select an option

  • Save aaronpowell/2722176 to your computer and use it in GitHub Desktop.

Select an option

Save aaronpowell/2722176 to your computer and use it in GitHub Desktop.
Postman minified but with whitespace preserved
(function () {
var a, b, c;
a = function () {
function a() {
this.first = null, this.last = null, this.length = 0
}
a.prototype.append = function (a) {
var b;
if ( !! a) {
b = {
data: a,
next: null,
prev: null
}, this.first ? (this.last.next = b, b.prev = this.last, this.last = b) : (this.first = b, this.last = b);
return this.length++
}
}, a.prototype.remove = function (a) {
if ( !! a) {
a.prev ? a.prev.next = a.next : (this.first = a.next, this.first && (this.first.prev = null));
return this.length--
}
};
return a
}(), c, b = function () {
function j() {}
var b, d, e, f, g, h, i;
g = function (a) {
return a.constructor === Array
}, i = function (a) {
return a.constructor === Function
}, h = function (a) {
return a.constructor === Date
}, d = function (c) {
return b[c] = {
subs: new a,
history: new a,
constructor: function () {}
}
}, b = {}, j.prototype.deliver = function () {
var a, e, f;
f = arguments[0], b[f] || d(f), a = [].slice.call(arguments, 1), a || (a = []), g(a) || (a = [a]), a = {
created: new Date,
lastPublished: new Date,
args: a
}, b[f].history.append(a), e = b[f].subs.first;
while (e) e.data.apply(this, a.args), e = e.next;
return c
}, j.prototype.deliverSync = function (a, e) {
var f;
b[a] || d(a), e || (e = []), g(e) || (e = [e]), e = {
created: new Date,
lastPublished: new Date,
args: e
}, b[a].history.append(e), f = b[a].subs.first;
while (f) setTimeout(function (a) {
return function () {
return a.data.apply(this, e.args)
}
}(f), 0), f = f.next;
return c
}, j.prototype.receive = function (a, e, f) {
var g;
b[a] || d(a), b[a].subs.append(e);
if (!f) {
g = b[a].history.first;
while (g) e.apply(this, g.data.args), g.data.lastPublished = new Date, g = g.next;
return c
}
}, j.prototype.retract = function (e, f) {
var g, h;
b[e] || d(e);
if (!f) b[e].subs = new a;
else {
h = b[e].subs, g = h.first;
while (g) g.data === f && h.remove(g), g = g.next
}
return c
}, j.prototype.dropMessages = function (g, j) {
b[g] || d(g), j ? (i(j) && (b[g].history = f(j, b[g].history)), h(j) && (b[g].history = e(j, b[g].history))) : b[g].history = new a;
return c.deliver("dropMessage." + g)
}, f = function (a, b) {
var c;
c = b.first;
while (c) a.apply(c.data) && b.remove(c), c = c.next;
return b
}, e = function (a, b) {
var c;
c = b.first;
while (c) c.data.created < a && b.remove(c), c = c.next;
return b
};
return j
}(), c = new b, this.LinkedList = a, this.postman = c
}).call(this)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment