dom-eventer
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t){r(this,e),this._name=t,this._subscriptions={},this._recentId=Date.now()}return i(e,[{key:"use",value:function(e){var t=this;return function(){return t[e].apply(t,arguments)}}},{key:"on",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("listen").apply(this,t)}},{key:"off",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("remove").apply(this,t)}},{key:"once",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("listen").apply(this,[].concat(t,[1]))}},{key:"isValidListener",value:function(e){return"function"==typeof e}},{key:"updateHitCount",value:function(e){if(this._subscriptions[e]){var t=this._subscriptions[e],n=t.hit,r=t.limit;this._subscriptions[e].hit+=1,r&&n===r&&this.remove(e)}}},{key:"listen",value:function(e,t,n,r){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=Array.from(arguments);if(o.length<3)throw new Error("`target`, `eventType` and `cb` params are required");if(!this.isValidListener(n))throw new TypeError("listener must be a function");"boolean"==typeof o[3]&&(i=o[3],r=null);var s=t+"."+(this._recentId+1);this._recentId+=1;var u=function(e,t){return function(){t.updateHitCount(e),n.apply(void 0,arguments)}}(s,this);return this._subscriptions[s]={limit:r,hit:0,type:t},e.addEventListener?(e.addEventListener(t,u,i),this._subscriptions[s].remove=function(){e.removeEventListener(t,u,i)}):e.attachEvent&&(e.attachEvent("on"+t,u),this._subscriptions[s].remove=function(){e.detachEvent("on"+t,u)}),s}},{key:"remove",value:function(e){this._subscriptions[e]&&(this._subscriptions[e].remove(),this._subscriptions[e].isRemove=!0)}},{key:"removeAll",value:function(){var e=this;Object.keys(this._subscriptions).forEach(function(t){e.remove(t)})}}]),e}();t.default=o}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t){r(this,e),this._name=t,this._subscriptions={},this._recentId=Date.now()}return i(e,[{key:"use",value:function(e){var t=this;return function(){return t[e].apply(t,arguments)}}},{key:"on",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("listen").apply(this,t)}},{key:"off",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("remove").apply(this,t)}},{key:"once",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this.use("listen").apply(this,[].concat(t,[1]))}},{key:"isValidListener",value:function(e){return"function"==typeof e}},{key:"updateHitCount",value:function(e){if(this._subscriptions[e]){var t=this._subscriptions[e],n=t.hit,r=t.limit;this._subscriptions[e].hit+=1,r&&n===r&&this.remove(e)}}},{key:"listen",value:function(e,t,n,r){var i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=Array.from(arguments);if(o.length<3)throw new Error("`target`, `eventType` and `cb` params are required");if(!this.isValidListener(n))throw new TypeError("listener must be a function");"boolean"==typeof o[3]&&(i=o[3],r=null);var s=t+"."+(this._recentId+1);this._recentId+=1;var u=function(e,t){return function(){t.updateHitCount(e),n.apply(void 0,arguments)}}(s,this);return this._subscriptions[s]={limit:r,hit:0,type:t},e.addEventListener?(e.addEventListener(t,u,i),this._subscriptions[s].remove=function(){e.removeEventListener(t,u,i)}):e.attachEvent&&(e.attachEvent("on"+t,u),this._subscriptions[s].remove=function(){e.detachEvent("on"+t,u)}),s}},{key:"remove",value:function(e){this._subscriptions[e]&&(this._subscriptions[e].remove(),this._subscriptions[e].isRemove=!0)}},{key:"removeAll",value:function(){var e=this;Object.keys(this._subscriptions).forEach(function(t){e.remove(t)})}}]),e}();t.default=o,e.exports=t.default}])}); |
{ | ||
"name": "dom-eventer", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A utility to control the occurence of DOM eventer", | ||
@@ -16,6 +16,7 @@ "main": "lib/index.js", | ||
"author": "Youchao Liu <liuyouchao111@gmail.com>", | ||
"license": "MIT", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-core": "^6.24.1", | ||
"babel-loader": "^7.0.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-preset-env": "^1.5.1", | ||
@@ -22,0 +23,0 @@ "rimraf": "^2.5.4", |
var path = require('path'); | ||
var webpack = require('webpack'); | ||
var baseConfig = { | ||
entry: './DOMEventer.js', | ||
var baseConfig = { | ||
entry: './DOMEventer.js', | ||
output: { | ||
@@ -18,3 +18,3 @@ libraryTarget: 'umd', | ||
] | ||
}, | ||
}, | ||
plugins: [ | ||
@@ -21,0 +21,0 @@ new webpack.optimize.UglifyJsPlugin() |
Sorry, the diff of this file is not supported yet
8206
8
6