diff --git a/component.json b/component.json index 39d9f00..6175c72 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name" : "monologue", - "version" : "0.1.4pre", + "version" : "0.1.4", "main" : ["lib/browser/monologue.js"], "dependencies": { "underscore": "~1.1.7" diff --git a/lib/monologue.js b/lib/monologue.js index ac86b5a..0ef3e2d 100644 --- a/lib/monologue.js +++ b/lib/monologue.js @@ -2,7 +2,7 @@ monologue.js 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.1.4pre + Version 0.1.4 */ (function ( root, factory ) { if ( typeof module === "object" && module.exports ) { diff --git a/lib/monologue.min.js b/lib/monologue.min.js index 3622ec5..ccdd7aa 100644 --- a/lib/monologue.min.js +++ b/lib/monologue.min.js @@ -2,6 +2,6 @@ monologue.js 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.1.4pre + Version 0.1.4 */ (function(e,t){typeof module=="object"&&module.exports?module.exports=function(e){return t(e)}:typeof define=="function"&&define.amd?define(["underscore"],function(n){return t(n,e)}):e.Monologue=t(e._,e)})(this,function(e,t,n){var r={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={}}},i=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}},s=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}},o=function(e,t,n){this.topic=e,this.callback=t,this.context=null,this.constraints=[],this.emitter=n};e.extend(o.prototype,{withContext:function(e){return this.context=e,this},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,r=e.after(t,function(){n.unsubscribe()}),i=n.callback;return n.callback=function(){i.apply(n.context,arguments),r()},n},once:function(){return this.disposeAfter(1)},distinctUntilChanged:function(){return this.withConstraint(new i),this},distinct:function(){return this.withConstraint(new s),this},unsubscribe:function(){this.emitter._subscriptions[this.topic]=e.without(this.emitter._subscriptions[this.topic],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},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},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}}),o.prototype.off=o.prototype.unsubscribe;var u=function(t,n){if(a.resolver.compare(t.topic,n.topic)&&e.all(t.constraints,function(e){return e(n.data,n)})&&typeof t.callback=="function")try{t.callback.apply(t.context,[n.data,n])}catch(r){a.debug&&typeof console!="undefined"&&typeof console.log=="function"&&(console.log("Monologue Emit Exception Caught"),console.log(r)),t.failed=!0,this._trackErrors&&(this._yuno||(this._yuno=[]),this._yuno.push({def:t,env:n,exception:r}))}},a=function(){};return a.prototype={on:function(e,t){var n=this;n._subscriptions||(n._subscriptions={});var r=new o(e,t,n),i=n._subscriptions[e];return i||(i=n._subscriptions[e]=[]),i.push(r),r},once:function(e,t){return this.on(e,t).once()},off:function(t,n){this._subscriptions||(this._subscriptions={});switch(arguments.length){case 0:e.each(this._subscriptions,function(t){e.each(t,function(e){e.unsubscribe()})}),this._subscriptions={};break;case 1:var r=Object.prototype.toString.call(t)==="[object String]"?"topic":t instanceof o?"def":"context";switch(r){case"topic":if(this._subscriptions[t])while(this._subscriptions[t].length)this._subscriptions[t].pop().unsubscribe();break;case"context":var i=[];e.each(this._subscriptions,function(n){e.each(e.clone(n),function(e,r){e.context===t&&(i.push(e.unsubscribe()),n.splice(r,1))})});break;default:t.unsubscribe()}break;default:e.each(e.clone(this._subscriptions[t]),function(e,n){e.context===t&&(i.push(e.unsubscribe()),this._subscriptions[t].splice(n,1))},this)}},emit:function(t,n){var r=this.getEnvelope(t,n);this._subscriptions||(this._subscriptions={}),e.each(this._subscriptions,function(e){var t=0,n=e.length,i;while(t