diff --git a/example/amd/js/libs/postal/postal.js b/example/amd/js/libs/postal/postal.js index 6f347ec..c2e46ad 100644 --- a/example/amd/js/libs/postal/postal.js +++ b/example/amd/js/libs/postal/postal.js @@ -315,15 +315,15 @@ var postal = { }, channel: function(exchange, topic) { - var exch = arguments.length === 2 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 2 ? topic : exchange; + var exch = topic ? exchange : DEFAULT_EXCHANGE, + tpc = topic || exchange; return new ChannelDefinition(exch, tpc); }, subscribe: function(exchange, topic, callback) { - var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 3 ? topic : exchange, - callbk = arguments.length === 3 ? callback : topic; + var callbk = callback || topic, + tpc = callback ? topic : exchange, + exch = callback ? exchange : DEFAULT_EXCHANGE; var channel = this.channel(exch, tpc); return channel.subscribe(callbk); }, diff --git a/example/standard/js/postal.js b/example/standard/js/postal.js index 28ec438..4fc5ba3 100644 --- a/example/standard/js/postal.js +++ b/example/standard/js/postal.js @@ -315,15 +315,15 @@ var postal = { }, channel: function(exchange, topic) { - var exch = arguments.length === 2 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 2 ? topic : exchange; + var exch = topic ? exchange : DEFAULT_EXCHANGE, + tpc = topic || exchange; return new ChannelDefinition(exch, tpc); }, subscribe: function(exchange, topic, callback) { - var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 3 ? topic : exchange, - callbk = arguments.length === 3 ? callback : topic; + var callbk = callback || topic, + tpc = callback ? topic : exchange, + exch = callback ? exchange : DEFAULT_EXCHANGE; var channel = this.channel(exch, tpc); return channel.subscribe(callbk); }, diff --git a/lib/browser/amd/postal.diagnostics.min.gz.js b/lib/browser/amd/postal.diagnostics.min.gz.js index e966d3c..a1b9e18 100644 Binary files a/lib/browser/amd/postal.diagnostics.min.gz.js and b/lib/browser/amd/postal.diagnostics.min.gz.js differ diff --git a/lib/browser/amd/postal.js b/lib/browser/amd/postal.js index 6f347ec..c2e46ad 100644 --- a/lib/browser/amd/postal.js +++ b/lib/browser/amd/postal.js @@ -315,15 +315,15 @@ var postal = { }, channel: function(exchange, topic) { - var exch = arguments.length === 2 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 2 ? topic : exchange; + var exch = topic ? exchange : DEFAULT_EXCHANGE, + tpc = topic || exchange; return new ChannelDefinition(exch, tpc); }, subscribe: function(exchange, topic, callback) { - var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE, - tpc = arguments.length === 3 ? topic : exchange, - callbk = arguments.length === 3 ? callback : topic; + var callbk = callback || topic, + tpc = callback ? topic : exchange, + exch = callback ? exchange : DEFAULT_EXCHANGE; var channel = this.channel(exch, tpc); return channel.subscribe(callbk); }, diff --git a/lib/browser/amd/postal.min.gz.js b/lib/browser/amd/postal.min.gz.js index a30da79..6d503d2 100644 Binary files a/lib/browser/amd/postal.min.gz.js and b/lib/browser/amd/postal.min.gz.js differ diff --git a/lib/browser/amd/postal.min.js b/lib/browser/amd/postal.min.js index 326256a..0059a3e 100644 --- a/lib/browser/amd/postal.min.js +++ b/lib/browser/amd/postal.min.js @@ -1 +1 @@ -define(["underscore"],function(a){var b="/",c=50,d=0,e="postal",f=function(){},g=function(c){var d={envelope:{}},e;switch(c.length){case 3:typeof c[1]=="Object"&&typeof c[2]=="Object"?(d.envelope.exchange=b,d.envelope.topic=c[0],d.payload=c[1],e=d.envelope,d.envelope=a.extend(e,c[2])):(d.envelope.exchange=c[0],d.envelope.topic=c[1],d.payload=c[2]);break;case 4:d.envelope.exchange=c[0],d.envelope.topic=c[1],d.payload=c[2],e=d.envelope,d.envelope=a.extend(e,c[3]);break;default:d.envelope.exchange=b,d.envelope.topic=c[0],d.payload=c[1]}return d},h=function(){var b;return function(c){var d=!1;return a.isString(c)?(d=c===b,b=c):(d=a.isEqual(c,b),b=a.clone(c)),!d}},i=function(a,b){this.exchange=a,this.topic=b};i.prototype={subscribe:function(a){var b=new j(this.exchange,this.topic,a);return m.configuration.bus.subscribe(b),b},publish:function(b,c){var d=a.extend({exchange:this.exchange,timeStamp:new Date,topic:this.topic},c);m.configuration.bus.publish(b,d)}};var j=function(a,b,g){this.exchange=a,this.topic=b,this.callback=g,this.priority=c,this.constraints=[],this.maxCalls=d,this.onHandled=f,this.context=null,m.publish(e,"subscription.created",{event:"subscription.created",exchange:a,topic:b})};j.prototype={unsubscribe:function(){m.configuration.bus.unsubscribe(this),m.publish(e,"subscription.removed",{event:"subscription.removed",exchange:this.exchange,topic:this.topic})},defer:function(){var a=this.callback;return this.callback=function(b){setTimeout(a,0,b)},this},disposeAfter:function(b){if(a.isNaN(b)||b<=0)throw"The value provided to disposeAfter (maxCalls) must be a number greater than zero.";var c=this.onHandled,d=a.after(b,a.bind(function(){this.unsubscribe(this)},this));return this.onHandled=function(){c.apply(this.context,arguments),d()},this},ignoreDuplicates:function(){return this.withConstraint(new h),this},whenHandledThenExecute:function(b){if(!a.isFunction(b))throw"Value provided to 'whenHandledThenExecute' must be a function";return this.onHandled=b,this},withConstraint:function(b){if(!a.isFunction(b))throw"Predicate constraint must be a function";return this.constraints.push(b),this},withConstraints:function(b){var c=this;return a.isArray(b)&&a.each(b,function(a){c.withConstraint(a)}),c},withContext:function(a){return this.context=a,this},withDebounce:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=a.debounce(c,b),this},withDelay:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=function(a){setTimeout(c,b,a)},this},withPriority:function(b){if(a.isNaN(b))throw"Priority must be a number";return this.priority=b,this},withThrottle:function(b){if(a.isNaN(b))throw"Milliseconds must be a number";var c=this.callback;return this.callback=a.throttle(c,b),this}};var k={cache:{},compare:function(a,b){if(this.cache[b]&&this.cache[b][a])return!0;var c=new RegExp("^"+this.regexify(a)+"$"),d=c.test(b);return d&&(this.cache[b]||(this.cache[b]={}),this.cache[b][a]=!0),d},regexify:function(a){return a.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/#/g,"[A-Z,a-z,0-9]*")}},l={subscriptions:{},wireTaps:[],publish:function(b,c){this.notifyTaps(b,c),a.each(this.subscriptions[c.exchange],function(d){a.each(d,function(d){m.configuration.resolver.compare(d.topic,c.topic)&&a.all(d.constraints,function(a){return a(b)})&&typeof d.callback=="function"&&(d.callback.apply(d.context,[b,c]),d.onHandled())})})},subscribe:function(a){var b,c,d,e,f;e=this.subscriptions[a.exchange]=this.subscriptions[a.exchange]||{},f=this.subscriptions[a.exchange][a.topic]=this.subscriptions[a.exchange][a.topic]||[],b=f.length-1;for(;b>=0;b--)if(f[b].priority<=a.priority){f.splice(b+1,0,a),c=!0;break}c||f.unshift(a)},notifyTaps:function(b,c){a.each(this.wireTaps,function(a){a(b,c)})},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c=0;b--)if(f[b].priority<=a.priority){f.splice(b+1,0,a),c=!0;break}c||f.unshift(a)},notifyTaps:function(b,c){a.each(this.wireTaps,function(a){a(b,c)})},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c=0;b--)if(f[b].priority<=a.priority){f.splice(b+1,0,a),c=!0;break}c||f.unshift(a)},notifyTaps:function(a,b){_.each(this.wireTaps,function(c){c(a,b)})},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c=0;b--)if(f[b].priority<=a.priority){f.splice(b+1,0,a),c=!0;break}c||f.unshift(a)},notifyTaps:function(a,b){_.each(this.wireTaps,function(c){c(a,b)})},unsubscribe:function(a){if(this.subscriptions[a.exchange][a.topic]){var b=this.subscriptions[a.exchange][a.topic].length,c=0;for(;c