From 314136cf4a0309452d8ff76b3fdde210c79ca7a4 Mon Sep 17 00:00:00 2001 From: Jim Cowart Date: Tue, 25 Sep 2012 21:23:06 -0400 Subject: [PATCH] Prepping for 0.7.2 tag --- README.md | 4 ++-- component.json | 2 +- example/amd/js/libs/postal/postal.js | 2 +- example/amd/js/libs/postal/postal.min.js | 2 +- example/node/client/js/lib/postal.js | 2 +- example/node/client/js/lib/postal.min.js | 2 +- example/node/messaging/postal.js | 4 ++-- example/standard/js/postal.js | 2 +- example/standard/js/postal.min.js | 2 +- lib/browser/classic-resolver.js | 2 +- lib/browser/classic-resolver.min.js | 2 +- lib/browser/postal.js | 2 +- lib/browser/postal.min.js | 2 +- lib/node/classic-resolver.js | 2 +- lib/node/postal.js | 4 ++-- package.json | 11 ++++++++--- src/node/postal.js | 2 +- 17 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index dba5636..fb841c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Postal.js -## Version 0.7.1 (Dual Licensed [MIT](http://www.opensource.org/licenses/mit-license) & [GPL](http://www.opensource.org/licenses/gpl-license)) +## Version 0.7.2 (Dual Licensed [MIT](http://www.opensource.org/licenses/mit-license) & [GPL](http://www.opensource.org/licenses/gpl-license)) ## What is it? Postal.js is an in-memory message bus - very loosely inspired by [AMQP](http://www.amqp.org/) - written in JavaScript. Postal.js runs in the browser, or on the server-side using Node.js. It takes a familiar "eventing-style" paradigm most JavaScript developers are already used to and extends it by providing "broker" and subscriber implementations which are more sophisticated than what you typically find in simple event delegation. @@ -22,7 +22,7 @@ Postal.js is in good company - there are many options for <airquotes>pub/s ## Recent Updates (IMPORTANT) -Version 0.7.1 of postal has implemented a bindings resolver that aligns with how AMQP handles wildcards in topical bindings. ***Please note that this effectively inverts how postal has handled wildcards up to now***. You can still use the old version of the bindings resolve by including the `classic-resolver.js` file in your project. If you want to use the new resolver, just use postal as-is and know that "#" matches 0 or more "words" (words are period-delimited segments of topics) and "*" matches exactly one word. +Version 0.7.2 of postal has implemented a bindings resolver that aligns with how AMQP handles wildcards in topical bindings. ***Please note that this effectively inverts how postal has handled wildcards up to now***. You can still use the old version of the bindings resolve by including the `classic-resolver.js` file in your project. If you want to use the new resolver, just use postal as-is and know that "#" matches 0 or more "words" (words are period-delimited segments of topics) and "*" matches exactly one word. ### Channels? WAT? A channel is a logical partition of topics. Conceptually, it's like a dedicated highway for a specific set of communication. At first glance it might seem like that's overkill for an environment that runs in an event loop, but it actually proves to be quite useful. Every library has architectural opinions that it either imposes or nudges you toward. Channel-oriented messaging nudges you to separate your communication by bounded context, and enables the kind of fine-tuned visibility you need into the interactions between components as your application grows. diff --git a/component.json b/component.json index 6b68993..d60940b 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "postal.js", - "version": "0.7.1", + "version": "0.7.2", "main": ["lib/standard/postal.min.js", "lib/standard/postal.js"], "dependencies": { "underscore": "~1.3.0" diff --git a/example/amd/js/libs/postal/postal.js b/example/amd/js/libs/postal/postal.js index 029a4a7..1d7a158 100644 --- a/example/amd/js/libs/postal/postal.js +++ b/example/amd/js/libs/postal/postal.js @@ -2,7 +2,7 @@ postal Author: Jim Cowart (http://freshbrewedcode.com/jimcowart) License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) - Version 0.7.1 + Version 0.7.2 */ (function ( root, doc, factory ) { if ( typeof define === "function" && define.amd ) { diff --git a/example/amd/js/libs/postal/postal.min.js b/example/amd/js/libs/postal/postal.min.js index 1b55961..da8f585 100644 --- a/example/amd/js/libs/postal/postal.min.js +++ b/example/amd/js/libs/postal/postal.min.js @@ -2,6 +2,6 @@ postal Author: Jim Cowart (http://freshbrewedcode.com/jimcowart) License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) - Version 0.7.1 + Version 0.7.2 */ (function(e,t,n){typeof define=="function"&&define.amd?define(["underscore"],function(r){return n(r,e,t)}):n(e._,e,t)})(this,document,function(e,t,n,r){var i="/",s=50,o=0,u="postal",a=function(){},f=function(){var t;return function(n){var r=!1;return e.isString(n)?(r=n===t,t=n):(r=e.isEqual(n,t),t=e.clone(n)),!r}},l=function(){var t=[];return function(n){var r=!e.any(t,function(t){return e.isObject(n)||e.isArray(n)?e.isEqual(n,t):n===t});return r&&t.push(n),r}},c=function(e,t){this.channel=e||i,this._topic=t||""};c.prototype={subscribe:function(){var e=arguments.length;if(e===1)return new h(this.channel,this._topic,arguments[0]);if(e===2)return new h(this.channel,arguments[0],arguments[1])},publish:function(e){var t=e||{},n={channel:this.channel,topic:this._topic,data:t};return t.topic&&t.data&&(n=t,n.channel=n.channel||this.channel),n.timeStamp=new Date,y.configuration.bus.publish(n),n},topic:function(e){return e===this._topic?this:new c(this.channel,e)}};var h=function(e,t,n){this.channel=e,this.topic=t,this.callback=n,this.priority=s,this.constraints=new Array(0),this.maxCalls=o,this.onHandled=a,this.context=null,y.configuration.bus.publish({channel:u,topic:"subscription.created",timeStamp:new Date,data:{event:"subscription.created",channel:e,topic:t}}),y.configuration.bus.subscribe(this)};h.prototype={unsubscribe:function(){y.configuration.bus.unsubscribe(this),y.configuration.bus.publish({channel:u,topic:"subscription.removed",timeStamp:new Date,data:{event:"subscription.removed",channel:this.channel,topic:this.topic}})},defer:function(){var e=this.callback;return this.callback=function(t){setTimeout(e,0,t)},this},disposeAfter:function(t){if(e.isNaN(t)||t<=0)throw"The value provided to disposeAfter (maxCalls) must be a number greater than zero.";var n=this.onHandled,r=e.after(t,e.bind(function(){this.unsubscribe(this)},this));return this.onHandled=function(){n.apply(this.context,arguments),r()},this},distinctUntilChanged:function(){return this.withConstraint(new f),this},distinct:function(){return this.withConstraint(new l),this},withConstraint:function(t){if(!e.isFunction(t))throw"Predicate constraint must be a function";return this.constraints.push(t),this},withConstraints:function(t){var n=this;return e.isArray(t)&&e.each(t,function(e){n.withConstraint(e)}),n},withContext:function(e){return this.context=e,this},withDebounce:function(t){if(e.isNaN(t))throw"Milliseconds must be a number";var n=this.callback;return this.callback=e.debounce(n,t),this},withDelay:function(t){if(e.isNaN(t))throw"Milliseconds must be a number";var n=this.callback;return this.callback=function(e){setTimeout(function(){n(e)},t)},this},withPriority:function(t){if(e.isNaN(t))throw"Priority must be a number";return this.priority=t,y.configuration.bus.changePriority(this),this},withThrottle:function(t){if(e.isNaN(t))throw"Milliseconds must be a number";var n=this.callback;return this.callback=e.throttle(n,t),this},subscribe:function(e){return this.callback=e,this}};var p={cache:{},compare:function(e,t){if(this.cache[t]&&this.cache[t][e])return!0;var n=("^"+e.replace(/\./g,"\\.").replace(/\*/g,"[A-Z,a-z,0-9]*").replace(/#/g,".*")+"$").replace("\\..*$","(\\..*)*$").replace("^.*\\.","^(.*\\.)*"),r=new RegExp(n),i=r.test(t);return i&&(this.cache[t]||(this.cache[t]={}),this.cache[t][e]=!0),i},reset:function(){this.cache={}}},d={addWireTap:function(e){var t=this;return t.wireTaps.push(e),function(){var n=t.wireTaps.indexOf(e);n!==-1&&t.wireTaps.splice(n,1)}},changePriority:function(t){var n,r;if(this.subscriptions[t.channel]&&this.subscriptions[t.channel][t.topic]){this.subscriptions[t.channel][t.topic]=e.without(this.subscriptions[t.channel][t.topic],t),n=this.subscriptions[t.channel][t.topic].length-1;for(;n>=0;n--)if(this.subscriptions[t.channel][t.topic][n].priority<=t.priority){this.subscriptions[t.channel][t.topic].splice(n+1,0,t),r=!0;break}r||this.subscriptions[t.channel][t.topic].unshift(t)}},publish:function(t){e.each(this.wireTaps,function(e){e(t.data,t)}),e.each(this.subscriptions[t.channel],function(n){e.each(e.clone(n),function(n){y.configuration.resolver.compare(n.topic,t.topic)&&e.all(n.constraints,function(e){return e(t.data,t)})&&typeof n.callback=="function"&&(n.callback.apply(n.context,[t.data,t]),n.onHandled())})})},reset:function(){this.subscriptions&&(e.each(this.subscriptions,function(t){e.each(t,function(e){while(e.length)e.pop().unsubscribe()})}),this.subscriptions={})},subscribe:function(e){var t,n,r,i=this.subscriptions[e.channel],s;return i||(i=this.subscriptions[e.channel]={}),s=this.subscriptions[e.channel][e.topic],s||(s=this.subscriptions[e.channel][e.topic]=new Array(0)),s.push(e),e},subscriptions:{},wireTaps:new Array(0),unsubscribe:function(e){if(this.subscriptions[e.channel][e.topic]){var t=this.subscriptions[e.channel][e.topic].length,n=0;for(;n=0;n--)if(this.subscriptions[t.channel][t.topic][n].priority<=t.priority){this.subscriptions[t.channel][t.topic].splice(n+1,0,t),r=!0;break}r||this.subscriptions[t.channel][t.topic].unshift(t)}},publish:function(t){e.each(this.wireTaps,function(e){e(t.data,t)}),e.each(this.subscriptions[t.channel],function(n){e.each(e.clone(n),function(n){y.configuration.resolver.compare(n.topic,t.topic)&&e.all(n.constraints,function(e){return e(t.data,t)})&&typeof n.callback=="function"&&(n.callback.apply(n.context,[t.data,t]),n.onHandled())})})},reset:function(){this.subscriptions&&(e.each(this.subscriptions,function(t){e.each(t,function(e){while(e.length)e.pop().unsubscribe()})}),this.subscriptions={})},subscribe:function(e){var t,n,r,i=this.subscriptions[e.channel],s;return i||(i=this.subscriptions[e.channel]={}),s=this.subscriptions[e.channel][e.topic],s||(s=this.subscriptions[e.channel][e.topic]=new Array(0)),s.push(e),e},subscriptions:{},wireTaps:new Array(0),unsubscribe:function(e){if(this.subscriptions[e.channel][e.topic]){var t=this.subscriptions[e.channel][e.topic].length,n=0;for(;n=0;n--)if(this.subscriptions[t.channel][t.topic][n].priority<=t.priority){this.subscriptions[t.channel][t.topic].splice(n+1,0,t),r=!0;break}r||this.subscriptions[t.channel][t.topic].unshift(t)}},publish:function(t){e.each(this.wireTaps,function(e){e(t.data,t)}),e.each(this.subscriptions[t.channel],function(n){e.each(e.clone(n),function(n){y.configuration.resolver.compare(n.topic,t.topic)&&e.all(n.constraints,function(e){return e(t.data,t)})&&typeof n.callback=="function"&&(n.callback.apply(n.context,[t.data,t]),n.onHandled())})})},reset:function(){this.subscriptions&&(e.each(this.subscriptions,function(t){e.each(t,function(e){while(e.length)e.pop().unsubscribe()})}),this.subscriptions={})},subscribe:function(e){var t,n,r,i=this.subscriptions[e.channel],s;return i||(i=this.subscriptions[e.channel]={}),s=this.subscriptions[e.channel][e.topic],s||(s=this.subscriptions[e.channel][e.topic]=new Array(0)),s.push(e),e},subscriptions:{},wireTaps:new Array(0),unsubscribe:function(e){if(this.subscriptions[e.channel][e.topic]){var t=this.subscriptions[e.channel][e.topic].length,n=0;for(;n=0;n--)if(this.subscriptions[t.channel][t.topic][n].priority<=t.priority){this.subscriptions[t.channel][t.topic].splice(n+1,0,t),r=!0;break}r||this.subscriptions[t.channel][t.topic].unshift(t)}},publish:function(t){e.each(this.wireTaps,function(e){e(t.data,t)}),e.each(this.subscriptions[t.channel],function(n){e.each(e.clone(n),function(n){y.configuration.resolver.compare(n.topic,t.topic)&&e.all(n.constraints,function(e){return e(t.data,t)})&&typeof n.callback=="function"&&(n.callback.apply(n.context,[t.data,t]),n.onHandled())})})},reset:function(){this.subscriptions&&(e.each(this.subscriptions,function(t){e.each(t,function(e){while(e.length)e.pop().unsubscribe()})}),this.subscriptions={})},subscribe:function(e){var t,n,r,i=this.subscriptions[e.channel],s;return i||(i=this.subscriptions[e.channel]={}),s=this.subscriptions[e.channel][e.topic],s||(s=this.subscriptions[e.channel][e.topic]=new Array(0)),s.push(e),e},subscriptions:{},wireTaps:new Array(0),unsubscribe:function(e){if(this.subscriptions[e.channel][e.topic]){var t=this.subscriptions[e.channel][e.topic].length,n=0;for(;n