mini-signals
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -93,4 +93,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MiniSignal = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
while (node) { | ||
if (node._once) this.detach(node); | ||
node._fn.apply(node._thisArg, arguments); | ||
if (node._once) this.detach(node); | ||
node = node._next; | ||
@@ -97,0 +97,0 @@ } |
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MiniSignal=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var MiniSignalBinding=function(){function MiniSignalBinding(fn,once,thisArg){if(once===undefined)once=false;_classCallCheck(this,MiniSignalBinding);this._fn=fn;this._once=once;this._thisArg=thisArg;this._next=this._prev=this._owner=null}_createClass(MiniSignalBinding,[{key:"detach",value:function detach(){if(this._owner===null)return false;this._owner.detach(this);return true}}]);return MiniSignalBinding}();function _addMiniSignalBinding(self,node){if(!self._head){self._head=node;self._tail=node}else{self._tail._next=node;node._prev=self._tail;self._tail=node}node._owner=self;return node}var MiniSignal=function(){function MiniSignal(){_classCallCheck(this,MiniSignal);this._head=this._tail=undefined}_createClass(MiniSignal,[{key:"handlers",value:function handlers(){var exists=arguments.length<=0||arguments[0]===undefined?false:arguments[0];var node=this._head;if(exists)return!!node;var ee=[];while(node){ee.push(node);node=node._next}return ee}},{key:"has",value:function has(node){if(!(node instanceof MiniSignalBinding)){throw new Error("MiniSignal#has(): First arg must be a MiniSignalBinding object.")}return node._owner===this}},{key:"dispatch",value:function dispatch(){var node=this._head;if(!node)return false;while(node){node._fn.apply(node._thisArg,arguments);if(node._once)this.detach(node);node=node._next}return true}},{key:"add",value:function add(fn){var thisArg=arguments.length<=1||arguments[1]===undefined?null:arguments[1];if(typeof fn!=="function"){throw new Error("MiniSignal#add(): First arg must be a Function.")}return _addMiniSignalBinding(this,new MiniSignalBinding(fn,false,thisArg))}},{key:"once",value:function once(fn){var thisArg=arguments.length<=1||arguments[1]===undefined?null:arguments[1];if(typeof fn!=="function"){throw new Error("MiniSignal#once(): First arg must be a Function.")}return _addMiniSignalBinding(this,new MiniSignalBinding(fn,true,thisArg))}},{key:"detach",value:function detach(node){if(!(node instanceof MiniSignalBinding)){throw new Error("MiniSignal#detach(): First arg must be a MiniSignalBinding object.")}if(node._owner!==this)return this;if(node._prev)node._prev._next=node._next;if(node._next)node._next._prev=node._prev;if(node===this._head){this._head=node._next;if(node._next===null){this._tail=null}}else if(node===this._tail){this._tail=node._prev;this._tail._next=null}node._owner=null;return this}},{key:"detachAll",value:function detachAll(){var node=this._head;if(!node)return this;this._head=this._tail=null;while(node){node._owner=null;node=node._next}return this}}]);return MiniSignal}();MiniSignal.MiniSignalBinding=MiniSignalBinding;exports["default"]=MiniSignal;module.exports=exports["default"]},{}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MiniSignal=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var MiniSignalBinding=function(){function MiniSignalBinding(fn,once,thisArg){if(once===undefined)once=false;_classCallCheck(this,MiniSignalBinding);this._fn=fn;this._once=once;this._thisArg=thisArg;this._next=this._prev=this._owner=null}_createClass(MiniSignalBinding,[{key:"detach",value:function detach(){if(this._owner===null)return false;this._owner.detach(this);return true}}]);return MiniSignalBinding}();function _addMiniSignalBinding(self,node){if(!self._head){self._head=node;self._tail=node}else{self._tail._next=node;node._prev=self._tail;self._tail=node}node._owner=self;return node}var MiniSignal=function(){function MiniSignal(){_classCallCheck(this,MiniSignal);this._head=this._tail=undefined}_createClass(MiniSignal,[{key:"handlers",value:function handlers(){var exists=arguments.length<=0||arguments[0]===undefined?false:arguments[0];var node=this._head;if(exists)return!!node;var ee=[];while(node){ee.push(node);node=node._next}return ee}},{key:"has",value:function has(node){if(!(node instanceof MiniSignalBinding)){throw new Error("MiniSignal#has(): First arg must be a MiniSignalBinding object.")}return node._owner===this}},{key:"dispatch",value:function dispatch(){var node=this._head;if(!node)return false;while(node){if(node._once)this.detach(node);node._fn.apply(node._thisArg,arguments);node=node._next}return true}},{key:"add",value:function add(fn){var thisArg=arguments.length<=1||arguments[1]===undefined?null:arguments[1];if(typeof fn!=="function"){throw new Error("MiniSignal#add(): First arg must be a Function.")}return _addMiniSignalBinding(this,new MiniSignalBinding(fn,false,thisArg))}},{key:"once",value:function once(fn){var thisArg=arguments.length<=1||arguments[1]===undefined?null:arguments[1];if(typeof fn!=="function"){throw new Error("MiniSignal#once(): First arg must be a Function.")}return _addMiniSignalBinding(this,new MiniSignalBinding(fn,true,thisArg))}},{key:"detach",value:function detach(node){if(!(node instanceof MiniSignalBinding)){throw new Error("MiniSignal#detach(): First arg must be a MiniSignalBinding object.")}if(node._owner!==this)return this;if(node._prev)node._prev._next=node._next;if(node._next)node._next._prev=node._prev;if(node===this._head){this._head=node._next;if(node._next===null){this._tail=null}}else if(node===this._tail){this._tail=node._prev;this._tail._next=null}node._owner=null;return this}},{key:"detachAll",value:function detachAll(){var node=this._head;if(!node)return this;this._head=this._tail=null;while(node){node._owner=null;node=node._next}return this}}]);return MiniSignal}();MiniSignal.MiniSignalBinding=MiniSignalBinding;exports["default"]=MiniSignal;module.exports=exports["default"]},{}]},{},[1])(1)}); |
@@ -9,2 +9,5 @@ CHANGELOG | ||
## 1.1.1 (2016-02-07) | ||
* Remove once listeners before calling, prevents loops | ||
## 1.1.0 (2015-11-03) | ||
@@ -11,0 +14,0 @@ * Added optional thisArg on MiniSignal#add and MiniSignal#once |
@@ -92,4 +92,4 @@ 'use strict'; | ||
while (node) { | ||
if (node._once) this.detach(node); | ||
node._fn.apply(node._thisArg, arguments); | ||
if (node._once) this.detach(node); | ||
node = node._next; | ||
@@ -96,0 +96,0 @@ } |
{ | ||
"name": "mini-signals", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "signals, in JavaScript, fast", | ||
@@ -5,0 +5,0 @@ "main": "lib/mini-signals.js", |
@@ -69,2 +69,6 @@ # mini-signals | ||
## API | ||
See [API.md](https://github.com/Hypercubed/mini-signals/blob/master/API.md) | ||
## License | ||
@@ -71,0 +75,0 @@ |
@@ -112,4 +112,4 @@ /* jshint -W097 */ | ||
while (node) { | ||
if (node._once) this.detach(node); | ||
node._fn.apply(node._thisArg, arguments); | ||
if (node._once) this.detach(node); | ||
node = node._next; | ||
@@ -116,0 +116,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24971
78