Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

any-event

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-event - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3-2.0.3-alpha.1.0

8

dist/index.d.ts
export interface DefaultTypeAndEventMap {
[type: string]: any;
}
export interface AEventListener<Event> {
(event: Event): void;
export interface AEventListener<Event, Key> {
(event: Event, key: Key): void;
}

@@ -27,3 +27,3 @@ export interface Interceptor {

*/
on<Key extends keyof TypeAndEventMap>(typeOrTypes: Key | Key[], listener: AEventListener<TypeAndEventMap[Key]>): this;
on<Key extends keyof TypeAndEventMap>(typeOrTypes: Key | Key[], listener: AEventListener<TypeAndEventMap[Key], Key>): this;
/**

@@ -44,3 +44,3 @@ * 按照监听器注册的顺序,同步地调用每个注册到名为 eventName 的事件的监听器,并传入提供的参数。

*/
off<Key extends keyof TypeAndEventMap>(type: Key, listener?: AEventListener<TypeAndEventMap[Key]>): void;
off<Key extends keyof TypeAndEventMap>(type: Key, listener?: AEventListener<TypeAndEventMap[Key], Key>): void;
/**

@@ -47,0 +47,0 @@ * 销毁实例

@@ -1,2 +0,2 @@

import{__values as t,__assign as r}from"tslib";var e=function(){function e(){this.__map={}}return e.prototype.beforeEach=function(t){this.__interceptor=t},e.prototype.on=function(r,e){var i,o,n=Array.isArray(r)?r:[r];try{for(var a=t(n),_=a.next();!_.done;_=a.next()){var p=_.value;this.__map[p]=this.__map[p]||[];var f=this.__map[p];f&&f.push(e)}}catch(t){i={error:t}}finally{try{_&&!_.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}return this},e.prototype.emit=function(t,r,e){var i=this;void 0!==this.__interceptor?this.__interceptor(t,(function(){i.__emit(t,r),e&&e()})):(this.__emit(t,r),e&&e())},e.prototype.__emit=function(e,i){var o,n,a=this.__map[e];if(Array.isArray(a)&&(null==a?void 0:a.length))try{for(var _=t(a),p=_.next();!p.done;p=_.next()){(0,p.value)(i)}}catch(t){o={error:t}}finally{try{p&&!p.done&&(n=_.return)&&n.call(_)}finally{if(o)throw o.error}}this.event=r(r({},i),{__type:e})},e.prototype.off=function(t,r){var e=this.__map[t];if(void 0!==e)if(void 0===r)delete this.__map[t];else{var i=e.findIndex((function(t){return t===r}));e.splice(i,1)}},e.prototype.destroy=function(){this.__map={}},e}();export{e as default};
class t{constructor(){this.__map={}}beforeEach(t){this.__interceptor=t}on(t,i){const s=Array.isArray(t)?t:[t];for(const t of s){this.__map[t]=this.__map[t]||[];const s=this.__map[t];s&&s.push(i)}return this}emit(t,i,s){void 0!==this.__interceptor?this.__interceptor(t,(()=>{this.__emit(t,i),s&&s()})):(this.__emit(t,i),s&&s())}__emit(t,i){const s=this.__map[t];if(Array.isArray(s)&&(null==s?void 0:s.length))for(const _ of s)_(i,t);this.event=i}off(t,i){const s=this.__map[t];if(void 0!==s)if(void 0===i)delete this.__map[t];else{const t=s.findIndex((t=>t===i));s.splice(t,1)}}destroy(){this.__map={}}}export{t as default};
//# sourceMappingURL=index.es.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=function(){function r(){this.__map={}}return r.prototype.beforeEach=function(t){this.__interceptor=t},r.prototype.on=function(r,e){var i,n,o=Array.isArray(r)?r:[r];try{for(var _=t.__values(o),a=_.next();!a.done;a=_.next()){var s=a.value;this.__map[s]=this.__map[s]||[];var p=this.__map[s];p&&p.push(e)}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=_.return)&&n.call(_)}finally{if(i)throw i.error}}return this},r.prototype.emit=function(t,r,e){var i=this;void 0!==this.__interceptor?this.__interceptor(t,(function(){i.__emit(t,r),e&&e()})):(this.__emit(t,r),e&&e())},r.prototype.__emit=function(r,e){var i,n,o=this.__map[r];if(Array.isArray(o)&&(null==o?void 0:o.length))try{for(var _=t.__values(o),a=_.next();!a.done;a=_.next()){(0,a.value)(e)}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=_.return)&&n.call(_)}finally{if(i)throw i.error}}this.event=t.__assign(t.__assign({},e),{__type:r})},r.prototype.off=function(t,r){var e=this.__map[t];if(void 0!==e)if(void 0===r)delete this.__map[t];else{var i=e.findIndex((function(t){return t===r}));e.splice(i,1)}},r.prototype.destroy=function(){this.__map={}},r}();exports.default=r;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=function(){function r(){this.__map={}}return r.prototype.beforeEach=function(t){this.__interceptor=t},r.prototype.on=function(r,e){var i,o,n=Array.isArray(r)?r:[r];try{for(var a=t.__values(n),_=a.next();!_.done;_=a.next()){var s=_.value;this.__map[s]=this.__map[s]||[];var p=this.__map[s];p&&p.push(e)}}catch(t){i={error:t}}finally{try{_&&!_.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}return this},r.prototype.emit=function(t,r,e){var i=this;void 0!==this.__interceptor?this.__interceptor(t,(function(){i.__emit(t,r),e&&e()})):(this.__emit(t,r),e&&e())},r.prototype.__emit=function(r,e){var i,o,n=this.__map[r];if(Array.isArray(n)&&(null==n?void 0:n.length))try{for(var a=t.__values(n),_=a.next();!_.done;_=a.next()){(0,_.value)(e,r)}}catch(t){i={error:t}}finally{try{_&&!_.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}this.event=e},r.prototype.off=function(t,r){var e=this.__map[t];if(void 0!==e)if(void 0===r)delete this.__map[t];else{var i=e.findIndex((function(t){return t===r}));e.splice(i,1)}},r.prototype.destroy=function(){this.__map={}},r}();exports.default=r;
//# sourceMappingURL=index.js.map
{
"name": "any-event",
"version": "2.0.2",
"version": "2.0.3-2.0.3-alpha.1.0",
"description": "小巧的事件模型",

@@ -22,3 +22,3 @@ "main": "dist/index.js",

"sideEffects": false,
"gitHead": "7df4617ecb8b89c720ce9747cdd77554c4966a88"
"gitHead": "5fe455a5e75ea4301ae73b35afba7f3929b1f07c"
}

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