multi-event
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ // multi-event 1.0.0 |
/*! multi-event 2015-09-04 */ | ||
"use strict";function _toConsumableArray(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),helpers={eventType:function(a){var b={valid:!1,type:"mono",splited:[]};b.splited=a.split(".");var c=!0,d=!1,e=void 0;try{for(var f,g=b.splited[Symbol.iterator]();!(c=(f=g.next()).done);c=!0){var h=f.value,i=/^[a-z0-9]+$/i.test(h),j="*"===h;if(!i&&!j)return b;j&&(b.type="multi")}}catch(k){d=!0,e=k}finally{try{!c&&g["return"]&&g["return"]()}finally{if(d)throw e}}return b.valid=!0,b.name=a,b},matches:function(a){return function(b){var c=b.split(".");if(a.length!==c.length)return!1;for(var d in a)if("*"!==c[d]&&c[d]!==a[d])return!1;return!0}}},MultiEvent=function(){function a(){_classCallCheck(this,a),this._mapMono=new Map,this._mapMulti=new Map}return _createClass(a,[{key:"on",value:function(a,b){var c=helpers.eventType(a);if(!c.valid)throw"invalid name";if("function"!=typeof b)throw"you must give me a function";var d=void 0;d="multi"!==c.type?this._mapMono:this._mapMulti;var e=void 0;return d.has(a)?e=d.get(a):(e=new Set,d.set(a,e)),e.add(b),this}},{key:"emit",value:function(a){var b=helpers.eventType(a);if(!b.valid)throw"invalid event";if("multi"===b.type)throw"you can not emit multiple events, may be in the next version";var c=this._mapMono.has(a)?[].concat(_toConsumableArray(this._mapMono.get(a))):[],d=[].concat(_toConsumableArray(this._mapMulti.keys())),e=d.filter(helpers.matches(b.splited)),f=[],g=!0,h=!1,i=void 0;try{for(var j,k=e[Symbol.iterator]();!(g=(j=k.next()).done);g=!0){var l=j.value;Array.prototype.push.apply(f,[].concat(_toConsumableArray(this._mapMulti.get(l))))}}catch(m){h=!0,i=m}finally{try{!g&&k["return"]&&k["return"]()}finally{if(h)throw i}}var n=c.concat(f),o=!0,p=!1,q=void 0;try{for(var r=arguments.length,s=Array(r>1?r-1:0),t=1;r>t;t++)s[t-1]=arguments[t];for(var u,v=n[Symbol.iterator]();!(o=(u=v.next()).done);o=!0){var w=u.value;w.apply({eventName:a},s)}}catch(m){p=!0,q=m}finally{try{!o&&v["return"]&&v["return"]()}finally{if(p)throw q}}return this}}]),a}();exports["default"]=MultiEvent,module.exports=exports["default"]; |
@@ -0,0 +0,0 @@ module.exports = function(grunt) { |
{ | ||
"name": "multi-event", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -36,3 +36,3 @@ "main": "dist/multi-event.js", | ||
"author": "Saad Y <yousfi.saad@gmail.com> (https://github.com/yousfiSaad/)", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -39,0 +39,0 @@ "url": "https://github.com/yousfiSaad/multi-event/issues" |
@@ -0,0 +0,0 @@ [![Build Status](https://travis-ci.org/yousfiSaad/multi-event.svg?branch=master)](https://travis-ci.org/yousfiSaad/multi-event) |
@@ -0,0 +0,0 @@ // multi-event 1.0.0 |
@@ -0,0 +0,0 @@ var assert = require('assert'); |
@@ -0,0 +0,0 @@ import Eventy from './src/multi-event' |
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
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
21761
437