Socket
Socket
Sign inDemoInstall

signals

Package Overview
Dependencies
Maintainers
1
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.7.4 to 0.8.0

dist/docs/symbols/Signal.html

68

dist/signals.js
/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */
/*global define:false, require:false, exports:false, module:false*/
/*global define:false, require:false, exports:false, module:false, signals:false */

@@ -8,3 +8,3 @@ /** @license

* Author: Miller Medeiros
* Version: 0.7.4 - Build: 252 (2012/02/24 10:30 PM)
* Version: 0.8.0 - Build: 264 (2012/07/31 10:58 AM)
*/

@@ -14,16 +14,2 @@

/**
* @namespace Signals Namespace - Custom event/messaging system based on AS3 Signals
* @name signals
*/
var signals = /** @lends signals */{
/**
* Signals Version Number
* @type String
* @const
*/
VERSION : '0.7.4'
};
// SignalBinding -------------------------------------------------

@@ -39,4 +25,4 @@ //================================================================

* @internal
* @name signals.SignalBinding
* @param {signals.Signal} signal Reference to Signal object that listener is currently bound to.
* @name SignalBinding
* @param {Signal} signal Reference to Signal object that listener is currently bound to.
* @param {Function} listener Handler function bound to the signal.

@@ -65,3 +51,3 @@ * @param {boolean} isOnce If binding should be executed just once.

* Context on which listener will be executed (object that should represent the `this` variable inside listener function).
* @memberOf signals.SignalBinding.prototype
* @memberOf SignalBinding.prototype
* @name context

@@ -74,3 +60,3 @@ * @type Object|undefined|null

* Reference to Signal object that listener is currently bound to.
* @type signals.Signal
* @type Signal
* @private

@@ -88,3 +74,3 @@ */

SignalBinding.prototype = /** @lends signals.SignalBinding.prototype */ {
SignalBinding.prototype = {

@@ -171,3 +157,3 @@ /**

/*global signals:false, SignalBinding:false*/
/*global SignalBinding:false*/

@@ -186,6 +172,7 @@ // Signal --------------------------------------------------------

* <br />- inspired by Robert Penner's AS3 Signals.
* @name Signal
* @author Miller Medeiros
* @constructor
*/
signals.Signal = function () {
function Signal() {
/**

@@ -197,7 +184,14 @@ * @type Array.<SignalBinding>

this._prevParams = null;
};
}
signals.Signal.prototype = {
Signal.prototype = {
/**
* Signals Version Number
* @type String
* @const
*/
VERSION : '0.8.0',
/**
* If Signal should keep record of previously dispatched parameters and

@@ -353,3 +347,3 @@ * automatically execute listener during `add()`/`addOnce()` if Signal was

* <p><strong>IMPORTANT:</strong> should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.</p>
* @see signals.Signal.prototype.disable
* @see Signal.prototype.disable
*/

@@ -392,3 +386,3 @@ halt : function () {

* Forget memorized arguments.
* @see signals.Signal.memorize
* @see Signal.memorize
*/

@@ -419,2 +413,21 @@ forget : function(){

// Namespace -----------------------------------------------------
//================================================================
/**
* Signals namespace
* @namespace
* @name signals
*/
var signals = Signal;
/**
* Custom event broadcaster
* @see Signal
*/
// alias for backwards compatibility (see #gh-44)
signals.Signal = Signal;
//exports to multiple environments

@@ -427,2 +440,3 @@ if(typeof define === 'function' && define.amd){ //AMD

//use string because of Google closure compiler ADVANCED_MODE
/*jslint sub:true */
global['signals'] = signals;

@@ -429,0 +443,0 @@ }

@@ -6,9 +6,9 @@ /*

Author: Miller Medeiros
Version: 0.7.4 - Build: 252 (2012/02/24 10:30 PM)
Version: 0.8.0 - Build: 264 (2012/07/31 10:58 AM)
*/
(function(h){function g(a,b,c,d,e){this._listener=b;this._isOnce=c;this.context=d;this._signal=a;this._priority=e||0}function f(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}var e={VERSION:"0.7.4"};g.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());return b},detach:function(){return this.isBound()?
this._signal.remove(this._listener,this.context):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+"]"}};e.Signal=function(){this._bindings=[];this._prevParams=null};e.Signal.prototype={memorize:!1,_shouldPropagate:!0,
active:!0,_registerListener:function(a,b,c,d){var e=this._indexOfListener(a,c);if(e!==-1){if(a=this._bindings[e],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new g(this,a,b,c,d),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);
(function(h){function g(a,b,c,e,d){this._listener=b;this._isOnce=c;this.context=e;this._signal=a;this._priority=d||0}function f(a,b){if(typeof a!=="function")throw Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b));}function d(){this._bindings=[];this._prevParams=null}g.prototype={active:!0,params:null,execute:function(a){var b;this.active&&this._listener&&(a=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,a),this._isOnce&&this.detach());
return b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):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+"]"}};d.prototype={VERSION:"0.8.0",memorize:!1,_shouldPropagate:!0,
active:!0,_registerListener:function(a,b,c,e){var d=this._indexOfListener(a,c);if(d!==-1){if(a=this._bindings[d],a.isOnce()!==b)throw Error("You cannot add"+(b?"":"Once")+"() then add"+(!b?"":"Once")+"() the same listener without removing the relationship first.");}else a=new g(this,a,b,c,e),this._addBinding(a);this.memorize&&this._prevParams&&a.execute(this._prevParams);return a},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);
this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c=this._bindings.length,d;c--;)if(d=this._bindings[c],d._listener===a&&d.context===b)return c;return-1},has:function(a,b){return this._indexOfListener(a,b)!==-1},add:function(a,b,c){f(a,"add");return this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){f(a,"addOnce");return this._registerListener(a,!0,b,c)},remove:function(a,b){f(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,
1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=
null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};typeof define==="function"&&define.amd?define(e):typeof module!=="undefined"&&module.exports?module.exports=e:h.signals=e})(this);
null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};d.Signal=d;typeof define==="function"&&define.amd?define(d):typeof module!=="undefined"&&module.exports?module.exports=d:h.signals=d})(this);

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

"homepage" : "http://millermedeiros.github.com/js-signals/",
"version" : "0.7.4",
"version" : "0.8.0",
"author" : {

@@ -9,0 +9,0 @@ "name" : "Miller Medeiros",

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