Socket
Socket
Sign inDemoInstall

signals

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signals - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

57

dist/signals.amd.js

@@ -8,4 +8,4 @@ /*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */

* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.6.2
* @build 182 (06/11/2011 02:42 AM)
* @version 0.6.3
* @build 187 (07/11/2011 10:14 AM)
*/

@@ -24,3 +24,3 @@ define(function(){

*/
VERSION : '0.6.2'
VERSION : '0.6.3'
};

@@ -93,2 +93,8 @@

active : true,
/**
* Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)
* @type Array|null
*/
params : null,

@@ -102,5 +108,6 @@ /**

execute : function (paramsArr) {
var r;
var handlerReturn, params;
if (this.active && !!this._listener) {
r = this._listener.apply(this.context, paramsArr);
params = this.params? this.params.concat(paramsArr) : paramsArr;
handlerReturn = this._listener.apply(this.context, params);
if (this._isOnce) {

@@ -110,3 +117,3 @@ this.detach();

}
return r;
return handlerReturn;
},

@@ -117,22 +124,20 @@

* - alias to: mySignal.remove(myBinding.getListener());
* @return {Function} Handler function bound to the signal.
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach : function () {
return this._signal.remove(this._listener);
return this.isBound()? this._signal.remove(this._listener) : null;
},
/**
* @return {Function} Handler function bound to the signal.
* @return {Boolean} `true` if binding is still bound to the signal and have a listener.
*/
getListener : function () {
return this._listener;
isBound : function () {
return (!!this._signal && !!this._listener);
},
/**
* Remove binding from signal and destroy any reference to external Objects (destroy SignalBinding object).
* <p><strong>IMPORTANT:</strong> calling methods on the binding instance after calling dispose will throw errors.</p>
* @return {Function} Handler function bound to the signal.
*/
dispose : function () {
this.detach();
this._destroy();
getListener : function () {
return this._listener;
},

@@ -161,3 +166,3 @@

toString : function () {
return '[SignalBinding isOnce: ' + this._isOnce + ', active: ' + this.active + ']';
return '[SignalBinding isOnce: ' + this._isOnce +', isBound: '+ this.isBound() +', active: ' + this.active + ']';
}

@@ -172,2 +177,8 @@

//================================================================
function validateListener(listener, fnName) {
if (typeof listener !== 'function') {
throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
}
}

@@ -213,6 +224,2 @@ /**

if (typeof listener !== 'function') {
throw new Error('listener is a required param of add() and addOnce() and should be a Function.');
}
var prevIndex = this._indexOfListener(listener),

@@ -235,3 +242,3 @@ binding;

/**
* @param {Function} binding
* @param {SignalBinding} binding
* @private

@@ -269,2 +276,3 @@ */

add : function (listener, scope, priority) {
validateListener(listener, 'add');
return this._registerListener(listener, false, scope, priority);

@@ -281,2 +289,3 @@ },

addOnce : function (listener, scope, priority) {
validateListener(listener, 'addOnce');
return this._registerListener(listener, true, scope, priority);

@@ -291,5 +300,3 @@ },

remove : function (listener) {
if (typeof listener !== 'function') {
throw new Error('listener is a required param of remove() and should be a Function.');
}
validateListener(listener, 'remove');

@@ -296,0 +303,0 @@ var i = this._indexOfListener(listener);

@@ -8,4 +8,4 @@ /*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */

* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.6.2
* @build 182 (06/11/2011 02:42 AM)
* @version 0.6.3
* @build 187 (07/11/2011 10:14 AM)
*/

@@ -23,3 +23,3 @@

*/
VERSION : '0.6.2'
VERSION : '0.6.3'
};

@@ -92,2 +92,8 @@

active : true,
/**
* Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)
* @type Array|null
*/
params : null,

@@ -101,5 +107,6 @@ /**

execute : function (paramsArr) {
var r;
var handlerReturn, params;
if (this.active && !!this._listener) {
r = this._listener.apply(this.context, paramsArr);
params = this.params? this.params.concat(paramsArr) : paramsArr;
handlerReturn = this._listener.apply(this.context, params);
if (this._isOnce) {

@@ -109,3 +116,3 @@ this.detach();

}
return r;
return handlerReturn;
},

@@ -116,22 +123,20 @@

* - alias to: mySignal.remove(myBinding.getListener());
* @return {Function} Handler function bound to the signal.
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach : function () {
return this._signal.remove(this._listener);
return this.isBound()? this._signal.remove(this._listener) : null;
},
/**
* @return {Function} Handler function bound to the signal.
* @return {Boolean} `true` if binding is still bound to the signal and have a listener.
*/
getListener : function () {
return this._listener;
isBound : function () {
return (!!this._signal && !!this._listener);
},
/**
* Remove binding from signal and destroy any reference to external Objects (destroy SignalBinding object).
* <p><strong>IMPORTANT:</strong> calling methods on the binding instance after calling dispose will throw errors.</p>
* @return {Function} Handler function bound to the signal.
*/
dispose : function () {
this.detach();
this._destroy();
getListener : function () {
return this._listener;
},

@@ -160,3 +165,3 @@

toString : function () {
return '[SignalBinding isOnce: ' + this._isOnce + ', active: ' + this.active + ']';
return '[SignalBinding isOnce: ' + this._isOnce +', isBound: '+ this.isBound() +', active: ' + this.active + ']';
}

@@ -171,2 +176,8 @@

//================================================================
function validateListener(listener, fnName) {
if (typeof listener !== 'function') {
throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
}
}

@@ -212,6 +223,2 @@ /**

if (typeof listener !== 'function') {
throw new Error('listener is a required param of add() and addOnce() and should be a Function.');
}
var prevIndex = this._indexOfListener(listener),

@@ -234,3 +241,3 @@ binding;

/**
* @param {Function} binding
* @param {SignalBinding} binding
* @private

@@ -268,2 +275,3 @@ */

add : function (listener, scope, priority) {
validateListener(listener, 'add');
return this._registerListener(listener, false, scope, priority);

@@ -280,2 +288,3 @@ },

addOnce : function (listener, scope, priority) {
validateListener(listener, 'addOnce');
return this._registerListener(listener, true, scope, priority);

@@ -290,5 +299,3 @@ },

remove : function (listener) {
if (typeof listener !== 'function') {
throw new Error('listener is a required param of remove() and should be a Function.');
}
validateListener(listener, 'remove');

@@ -295,0 +302,0 @@ var i = this._indexOfListener(listener);

@@ -8,4 +8,4 @@ /*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */

* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.6.2
* @build 182 (06/11/2011 02:42 AM)
* @version 0.6.3
* @build 187 (07/11/2011 10:14 AM)
*/

@@ -24,3 +24,3 @@ (function(global){

*/
VERSION : '0.6.2'
VERSION : '0.6.3'
};

@@ -93,2 +93,8 @@

active : true,
/**
* Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)
* @type Array|null
*/
params : null,

@@ -102,5 +108,6 @@ /**

execute : function (paramsArr) {
var r;
var handlerReturn, params;
if (this.active && !!this._listener) {
r = this._listener.apply(this.context, paramsArr);
params = this.params? this.params.concat(paramsArr) : paramsArr;
handlerReturn = this._listener.apply(this.context, params);
if (this._isOnce) {

@@ -110,3 +117,3 @@ this.detach();

}
return r;
return handlerReturn;
},

@@ -117,22 +124,20 @@

* - alias to: mySignal.remove(myBinding.getListener());
* @return {Function} Handler function bound to the signal.
* @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached.
*/
detach : function () {
return this._signal.remove(this._listener);
return this.isBound()? this._signal.remove(this._listener) : null;
},
/**
* @return {Function} Handler function bound to the signal.
* @return {Boolean} `true` if binding is still bound to the signal and have a listener.
*/
getListener : function () {
return this._listener;
isBound : function () {
return (!!this._signal && !!this._listener);
},
/**
* Remove binding from signal and destroy any reference to external Objects (destroy SignalBinding object).
* <p><strong>IMPORTANT:</strong> calling methods on the binding instance after calling dispose will throw errors.</p>
* @return {Function} Handler function bound to the signal.
*/
dispose : function () {
this.detach();
this._destroy();
getListener : function () {
return this._listener;
},

@@ -161,3 +166,3 @@

toString : function () {
return '[SignalBinding isOnce: ' + this._isOnce + ', active: ' + this.active + ']';
return '[SignalBinding isOnce: ' + this._isOnce +', isBound: '+ this.isBound() +', active: ' + this.active + ']';
}

@@ -172,2 +177,8 @@

//================================================================
function validateListener(listener, fnName) {
if (typeof listener !== 'function') {
throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
}
}

@@ -213,6 +224,2 @@ /**

if (typeof listener !== 'function') {
throw new Error('listener is a required param of add() and addOnce() and should be a Function.');
}
var prevIndex = this._indexOfListener(listener),

@@ -235,3 +242,3 @@ binding;

/**
* @param {Function} binding
* @param {SignalBinding} binding
* @private

@@ -269,2 +276,3 @@ */

add : function (listener, scope, priority) {
validateListener(listener, 'add');
return this._registerListener(listener, false, scope, priority);

@@ -281,2 +289,3 @@ },

addOnce : function (listener, scope, priority) {
validateListener(listener, 'addOnce');
return this._registerListener(listener, true, scope, priority);

@@ -291,5 +300,3 @@ },

remove : function (listener) {
if (typeof listener !== 'function') {
throw new Error('listener is a required param of remove() and should be a Function.');
}
validateListener(listener, 'remove');

@@ -296,0 +303,0 @@ var i = this._indexOfListener(listener);

@@ -5,5 +5,5 @@ /*!

* @author Miller Medeiros <http://millermedeiros.com/>
* @version 0.6.2
* @build 182 (06/11/2011 02:42 AM)
* @version 0.6.3
* @build 187 (07/11/2011 10:14 AM)
*/
(function(c){var a={VERSION:"0.6.2"};function b(h,g,e,f,d){this._listener=g;this._isOnce=e;this.context=f;this._signal=h;this._priority=d||0}b.prototype={active:true,execute:function(d){var e;if(this.active&&!!this._listener){e=this._listener.apply(this.context,d);if(this._isOnce){this.detach()}}return e},detach:function(){return this._signal.remove(this._listener)},getListener:function(){return this._listener},dispose:function(){this.detach();this._destroy()},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce: "+this._isOnce+", active: "+this.active+"]"}};a.Signal=function(){this._bindings=[]};a.Signal.prototype={_shouldPropagate:true,active:true,_registerListener:function(h,g,f,e){if(typeof h!=="function"){throw new Error("listener is a required param of add() and addOnce() and should be a Function.")}var d=this._indexOfListener(h),i;if(d!==-1){i=this._bindings[d];if(i.isOnce()!==g){throw new Error("You cannot add"+(g?"":"Once")+"() then add"+(!g?"":"Once")+"() the same listener without removing the relationship first.")}}else{i=new b(this,h,g,f,e);this._addBinding(i)}return i},_addBinding:function(d){var e=this._bindings.length;do{--e}while(this._bindings[e]&&d._priority<=this._bindings[e]._priority);this._bindings.splice(e+1,0,d)},_indexOfListener:function(d){var e=this._bindings.length;while(e--){if(this._bindings[e]._listener===d){return e}}return -1},add:function(f,e,d){return this._registerListener(f,false,e,d)},addOnce:function(f,e,d){return this._registerListener(f,true,e,d)},remove:function(e){if(typeof e!=="function"){throw new Error("listener is a required param of remove() and should be a Function.")}var d=this._indexOfListener(e);if(d!==-1){this._bindings[d]._destroy();this._bindings.splice(d,1)}return e},removeAll:function(){var d=this._bindings.length;while(d--){this._bindings[d]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(e){if(!this.active){return}var d=Array.prototype.slice.call(arguments),g=this._bindings.slice(),f=this._bindings.length;this._shouldPropagate=true;do{f--}while(g[f]&&this._shouldPropagate&&g[f].execute(d)!==false)},dispose:function(){this.removeAll();delete this._bindings},toString:function(){return"[Signal active: "+this.active+" numListeners: "+this.getNumListeners()+"]"}};c.signals=a}(window||this));
(function(d){var b={VERSION:"0.6.3"};function c(i,h,f,g,e){this._listener=h;this._isOnce=f;this.context=g;this._signal=i;this._priority=e||0}c.prototype={active:true,params:null,execute:function(e){var g,f;if(this.active&&!!this._listener){f=this.params?this.params.concat(e):e;g=this._listener.apply(this.context,f);if(this._isOnce){this.detach()}}return g},detach:function(){return this.isBound()?this._signal.remove(this._listener):null},isBound:function(){return(!!this._signal&&!!this._listener)},getListener:function(){return this._listener},_destroy:function(){delete this._signal;delete this._listener;delete this.context},isOnce:function(){return this._isOnce},toString:function(){return"[SignalBinding isOnce: "+this._isOnce+", isBound: "+this.isBound()+", active: "+this.active+"]"}};function a(e,f){if(typeof e!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",f))}}b.Signal=function(){this._bindings=[]};b.Signal.prototype={_shouldPropagate:true,active:true,_registerListener:function(i,h,g,f){var e=this._indexOfListener(i),j;if(e!==-1){j=this._bindings[e];if(j.isOnce()!==h){throw new Error("You cannot add"+(h?"":"Once")+"() then add"+(!h?"":"Once")+"() the same listener without removing the relationship first.")}}else{j=new c(this,i,h,g,f);this._addBinding(j)}return j},_addBinding:function(e){var f=this._bindings.length;do{--f}while(this._bindings[f]&&e._priority<=this._bindings[f]._priority);this._bindings.splice(f+1,0,e)},_indexOfListener:function(e){var f=this._bindings.length;while(f--){if(this._bindings[f]._listener===e){return f}}return -1},add:function(g,f,e){a(g,"add");return this._registerListener(g,false,f,e)},addOnce:function(g,f,e){a(g,"addOnce");return this._registerListener(g,true,f,e)},remove:function(f){a(f,"remove");var e=this._indexOfListener(f);if(e!==-1){this._bindings[e]._destroy();this._bindings.splice(e,1)}return f},removeAll:function(){var e=this._bindings.length;while(e--){this._bindings[e]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(f){if(!this.active){return}var e=Array.prototype.slice.call(arguments),h=this._bindings.slice(),g=this._bindings.length;this._shouldPropagate=true;do{g--}while(h[g]&&this._shouldPropagate&&h[g].execute(e)!==false)},dispose:function(){this.removeAll();delete this._bindings},toString:function(){return"[Signal active: "+this.active+" numListeners: "+this.getNumListeners()+"]"}};d.signals=b}(window||this));

@@ -6,3 +6,3 @@ {

"homepage" : "http://millermedeiros.github.com/js-signals/",
"version" : "0.6.2",
"version" : "0.6.3",
"author" : "Miller Medeiros",

@@ -9,0 +9,0 @@ "repository" : {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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