Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mediator-js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mediator-js - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

8

lib/mediator.js
/*jslint bitwise: true, nomen: true, plusplus: true, white: true */
/*!
* Mediator.js Library v0.9.8
* Mediator.js Library v0.10.1
* https://github.com/ajacksified/Mediator.js
*
* Copyright 2013, Jack Lawson
* Copyright 2018, Jack Lawson
* MIT Licensed (http://www.opensource.org/licenses/mit-license.php)

@@ -13,3 +13,3 @@ *

*
* Last update: October 19 2013
* Last update: 22 Mar 2018
*/

@@ -375,5 +375,5 @@

Mediator.Subscriber = Subscriber;
Mediator.version = "0.9.8";
Mediator.version = "0.10.1";
return Mediator;
}));

@@ -1,1 +0,13 @@

!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return a.Mediator=b(),a.Mediator}):"undefined"!=typeof exports?exports.Mediator=b():a.Mediator=b()}(this,function(){"use strict";function a(){var a=function(){return(0|65536*(1+Math.random())).toString(16).substring(1)};return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}function b(c,d,e){return this instanceof b?(this.id=a(),this.fn=c,this.options=d,this.context=e,this.channel=null,void 0):new b(c,d,e)}function c(a,b){return this instanceof c?(this.namespace=a||"",this._subscribers=[],this._channels={},this._parent=b,this.stopped=!1,void 0):new c(a)}function d(){return this instanceof d?(this._channels=new c(""),void 0):new d}return b.prototype={update:function(a){a&&(this.fn=a.fn||this.fn,this.context=a.context||this.context,this.options=a.options||this.options,this.channel&&this.options&&void 0!==this.options.priority&&this.channel.setPriority(this.id,this.options.priority))}},c.prototype={addSubscriber:function(a,c,d){var e=new b(a,c,d);return c&&void 0!==c.priority?(c.priority=c.priority>>0,c.priority<0&&(c.priority=0),c.priority>=this._subscribers.length&&(c.priority=this._subscribers.length-1),this._subscribers.splice(c.priority,0,e)):this._subscribers.push(e),e.channel=this,e},stopPropagation:function(){this.stopped=!0},getSubscriber:function(a){var b=0,c=this._subscribers.length;for(c;c>b;b++)if(this._subscribers[b].id===a||this._subscribers[b].fn===a)return this._subscribers[b]},setPriority:function(a,b){var e,f,g,h,c=0,d=0;for(d=0,h=this._subscribers.length;h>d&&this._subscribers[d].id!==a&&this._subscribers[d].fn!==a;d++)c++;e=this._subscribers[c],f=this._subscribers.slice(0,c),g=this._subscribers.slice(c+1),this._subscribers=f.concat(g),this._subscribers.splice(b,0,e)},addChannel:function(a){this._channels[a]=new c((this.namespace?this.namespace+":":"")+a,this)},hasChannel:function(a){return this._channels.hasOwnProperty(a)},returnChannel:function(a){return this._channels[a]},removeSubscriber:function(a){var b=this._subscribers.length-1;if(!a)return this._subscribers=[],void 0;for(b;b>=0;b--)(this._subscribers[b].fn===a||this._subscribers[b].id===a)&&(this._subscribers[b].channel=null,this._subscribers.splice(b,1))},publish:function(a){var e,g,h,b=0,c=this._subscribers.length,d=!1;for(c;c>b;b++)d=!1,e=this._subscribers[b],this.stopped||(g=this._subscribers.length,void 0!==e.options&&"function"==typeof e.options.predicate?e.options.predicate.apply(e.context,a)&&(d=!0):d=!0),d&&(e.options&&void 0!==e.options.calls&&(e.options.calls--,e.options.calls<1&&this.removeSubscriber(e.id)),e.fn.apply(e.context,a),h=this._subscribers.length,c=h,h===g-1&&b--);this._parent&&this._parent.publish(a),this.stopped=!1}},d.prototype={getChannel:function(a,b){var c=this._channels,d=a.split(":"),e=0,f=d.length;if(""===a)return c;if(d.length>0)for(f;f>e;e++){if(!c.hasChannel(d[e])){if(b)break;c.addChannel(d[e])}c=c.returnChannel(d[e])}return c},subscribe:function(a,b,c,d){var e=this.getChannel(a||"",!1);return c=c||{},d=d||{},e.addSubscriber(b,c,d)},once:function(a,b,c,d){return c=c||{},c.calls=1,this.subscribe(a,b,c,d)},getSubscriber:function(a,b){var c=this.getChannel(b||"",!0);return c.namespace!==b?null:c.getSubscriber(a)},remove:function(a,b){var c=this.getChannel(a||"",!0);return c.namespace!==a?!1:(c.removeSubscriber(b),void 0)},publish:function(a){var b=this.getChannel(a||"",!1);if(b.namespace!==a)return null;var c=Array.prototype.slice.call(arguments,1);c.push(b),b.publish(c)}},d.prototype.on=d.prototype.subscribe,d.prototype.bind=d.prototype.subscribe,d.prototype.emit=d.prototype.publish,d.prototype.trigger=d.prototype.publish,d.prototype.off=d.prototype.remove,d.Channel=c,d.Subscriber=b,d.version="0.9.8",d});
/*!
* Mediator.js Library v0.10.1
* https://github.com/ajacksified/Mediator.js
*
* Copyright 2018, Jack Lawson
* MIT Licensed (http://www.opensource.org/licenses/mit-license.php)
*
* For more information: http://thejacklawson.com/2011/06/mediators-for-modularized-asynchronous-programming-in-javascript/index.html
* Project on GitHub: https://github.com/ajacksified/Mediator.js
*
* Last update: 22 Mar 2018
*/
!function(t,s){"use strict";"function"==typeof define&&define.amd?define([],function(){return t.Mediator=s(),t.Mediator}):"undefined"!=typeof exports?exports.Mediator=s():t.Mediator=s()}(this,function(){"use strict";function t(s,i,e){if(!(this instanceof t))return new t(s,i,e);var r;this.id=(r=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)})()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r(),this.fn=s,this.options=i,this.context=e,this.channel=null}function s(t,i){if(!(this instanceof s))return new s(t);this.namespace=t||"",this._subscribers=[],this._channels={},this._parent=i,this.stopped=!1}function i(){if(!(this instanceof i))return new i;this._channels=new s("")}return t.prototype.update=function(t){t&&(this.fn=t.fn||this.fn,this.context=t.context||this.context,this.options=t.options||this.options,this.channel&&this.options&&void 0!==this.options.priority&&this.channel.setPriority(this.id,this.options.priority))},s.prototype.addSubscriber=function(s,i,e){var r=new t(s,i,e);return i&&void 0!==i.priority?(i.priority=i.priority>>0,i.priority<0&&(i.priority=0),i.priority>=this._subscribers.length&&(i.priority=this._subscribers.length-1),this._subscribers.splice(i.priority,0,r)):this._subscribers.push(r),r.channel=this,r},s.prototype.stopPropagation=function(){this.stopped=!0},s.prototype.getSubscriber=function(t){for(var s=0,i=this._subscribers.length;s<i;s++)if(this._subscribers[s].id===t||this._subscribers[s].fn===t)return this._subscribers[s]},s.prototype.setPriority=function(t,s){var i,e,r,n,o=0,p=0;for(p=0,n=this._subscribers.length;p<n&&(this._subscribers[p].id!==t&&this._subscribers[p].fn!==t);p++)o++;i=this._subscribers[o],e=this._subscribers.slice(0,o),r=this._subscribers.slice(o+1),this._subscribers=e.concat(r),this._subscribers.splice(s,0,i)},s.prototype.addChannel=function(t){this._channels[t]=new s((this.namespace?this.namespace+":":"")+t,this)},s.prototype.hasChannel=function(t){return this._channels.hasOwnProperty(t)},s.prototype.returnChannel=function(t){return this._channels[t]},s.prototype.removeSubscriber=function(t){var s=this._subscribers.length-1;if(t)for(;s>=0;s--)this._subscribers[s].fn!==t&&this._subscribers[s].id!==t||(this._subscribers[s].channel=null,this._subscribers.splice(s,1));else this._subscribers=[]},s.prototype.publish=function(t){for(var s,i,e,r=0,n=this._subscribers.length,o=!1;r<n;r++)o=!1,s=this._subscribers[r],this.stopped||(i=this._subscribers.length,void 0!==s.options&&"function"==typeof s.options.predicate?s.options.predicate.apply(s.context,t)&&(o=!0):o=!0),o&&(s.options&&void 0!==s.options.calls&&(s.options.calls--,s.options.calls<1&&this.removeSubscriber(s.id)),s.fn.apply(s.context,t),n=e=this._subscribers.length,e===i-1&&r--);this._parent&&this._parent.publish(t),this.stopped=!1},i.prototype.getChannel=function(t,s){var i=this._channels,e=t.split(":"),r=0,n=e.length;if(""===t)return i;if(e.length>0)for(;r<n;r++){if(!i.hasChannel(e[r])){if(s)break;i.addChannel(e[r])}i=i.returnChannel(e[r])}return i},i.prototype.subscribe=function(t,s,i,e){return i=i||{},e=e||{},this.getChannel(t||"",!1).addSubscriber(s,i,e)},i.prototype.once=function(t,s,i,e){return(i=i||{}).calls=1,this.subscribe(t,s,i,e)},i.prototype.getSubscriber=function(t,s){var i=this.getChannel(s||"",!0);return i.namespace!==s?null:i.getSubscriber(t)},i.prototype.remove=function(t,s){var i=this.getChannel(t||"",!0);if(i.namespace!==t)return!1;i.removeSubscriber(s)},i.prototype.publish=function(t){var s=this.getChannel(t||"",!1);if(s.namespace!==t)return null;var i=Array.prototype.slice.call(arguments,1);i.push(s),s.publish(i)},i.prototype.on=i.prototype.subscribe,i.prototype.bind=i.prototype.subscribe,i.prototype.emit=i.prototype.publish,i.prototype.trigger=i.prototype.publish,i.prototype.off=i.prototype.remove,i.Channel=s,i.Subscriber=t,i.version="0.10.1",i});
{
"name": "mediator-js",
"version": "0.10.0",
"version": "0.10.1",
"description": "Flexible event management. Implementation of the mediator pattern.",

@@ -5,0 +5,0 @@ "author": "Jack Lawson <jlawson@olivinelabs.com>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc