multi-event
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/multi-event.js", |
@@ -46,4 +46,4 @@ [![Build Status](https://travis-ci.org/yousfiSaad/multi-event.svg?branch=master)](https://travis-ci.org/yousfiSaad/multi-event) | ||
myEvents.on('event.subevent1', callBack1) | ||
.on('event.subevent2', callBack2); | ||
.on('event.*', callBack); // this callnack is trigged to all 'event' sub-events | ||
.on('event.subevent2', callBack2) | ||
.on('event.*', callBack); // this callBack is trigged to all 'event' sub-events | ||
@@ -61,5 +61,5 @@ myEvents.emit('event.subevent1', 'this string will be logged twice'); | ||
# EcmaScript6 | ||
This module is writed in ES6, you can find the in `src/multi-event-es6.js` | ||
This module is writen in ES6, you can find the in `src/multi-event-es6.js` | ||
For building your modification run `npm build`, the files `multi-event.js` and `multi-event.min.js` are created in `dist` folder | ||
For building your modification run `npm run build`, the files `multi-event.js` and `multi-event.min.js` are created in `dist` folder | ||
@@ -66,0 +66,0 @@ ## Build and test |
@@ -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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22090
14
461
0