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

@boost/event

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boost/event - npm Package Compare versions

Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1

3

lib/BailEvent.d.ts
import BaseEvent from './BaseEvent';
import { Scope } from './types';
export default class BailEvent<Args extends unknown[]> extends BaseEvent<Args, boolean | void> {
export default class BailEvent<Args extends unknown[], Scope extends string = string> extends BaseEvent<boolean | void, Args, Scope> {
/**

@@ -5,0 +4,0 @@ * Synchronously execute listeners with the defined arguments.

@@ -1,4 +0,4 @@

import { Listener, Scope } from './types';
export default abstract class BaseEvent<Args extends unknown[], Return> {
listeners: Map<string, Set<Listener<Args, Return>>>;
import { Listener, WildstarScope } from './types';
export default abstract class BaseEvent<Return, Args extends unknown[], Scope extends string = string> {
listeners: Map<Scope | WildstarScope, Set<Listener<Args, Return>>>;
name: string;

@@ -17,3 +17,3 @@ constructor(name: string);

*/
getScopes(): string[];
getScopes(): (Scope | WildstarScope)[];
/**

@@ -38,3 +38,3 @@ * Register a listener to the event.

*/
protected validateName(name: string, type: string): string;
protected validateName<N extends string>(name: N, type: string): N;
/**

@@ -41,0 +41,0 @@ * Emit the event by executing all scoped listeners with the defined arguments.

@@ -24,4 +24,4 @@ "use strict";

*/
getListeners(scope = constants_1.DEFAULT_SCOPE) {
const key = this.validateName(scope, 'scope');
getListeners(scope) {
const key = this.validateName(scope || constants_1.WILDCARD_SCOPE, 'scope');
if (!this.listeners.has(key)) {

@@ -76,3 +76,3 @@ this.listeners.set(key, new Set());

validateName(name, type) {
if (type === 'scope' && name === constants_1.DEFAULT_SCOPE) {
if (type === 'scope' && name === constants_1.WILDCARD_SCOPE) {
return name;

@@ -79,0 +79,0 @@ }

import BaseEvent from './BaseEvent';
import { Scope } from './types';
export default class ConcurrentEvent<Args extends unknown[]> extends BaseEvent<Args, Promise<unknown>> {
export default class ConcurrentEvent<Args extends unknown[], Scope extends string = string> extends BaseEvent<Promise<unknown>, Args, Scope> {
/**

@@ -5,0 +4,0 @@ * Asynchronously execute listeners for with the defined arguments.

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

export declare const DEFAULT_SCOPE = "*";
export declare const WILDCARD_SCOPE = "*";
export declare const EVENT_NAME_PATTERN: RegExp;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_SCOPE = '*';
exports.WILDCARD_SCOPE = '*';
exports.EVENT_NAME_PATTERN = /^[a-z]{1}[-.a-z0-9]*[a-z]{1}$/u;
import BaseEvent from './BaseEvent';
import { Scope } from './types';
export default class Event<Args extends unknown[]> extends BaseEvent<Args, void> {
export default class Event<Args extends unknown[], Scope extends string = string> extends BaseEvent<void, Args, Scope> {
/**

@@ -5,0 +4,0 @@ * Synchronously execute listeners with the defined arguments.

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

export declare type Listener<A extends unknown[], R> = A extends [infer A1, infer A2, infer A3] ? (a1: A1, a2: A2, a3: A3) => R : A extends [infer A1, infer A2] ? (a1: A1, a2: A2) => R : A extends [infer A1] ? (a1: A1) => R : A extends unknown[] ? (...args: A) => R : never;
export declare type Scope = string;
export declare type Listener<A extends unknown[], R> = A extends [infer A1, infer A2, infer A3, infer A4, infer A5] ? (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => R : A extends [infer A1, infer A2, infer A3, infer A4] ? (a1: A1, a2: A2, a3: A3, a4: A4) => R : A extends [infer A1, infer A2, infer A3] ? (a1: A1, a2: A2, a3: A3) => R : A extends [infer A1, infer A2] ? (a1: A1, a2: A2) => R : A extends [infer A1] ? (a1: A1) => R : A extends unknown[] ? (...args: A) => R : never;
export declare type WildstarScope = '*';
import BaseEvent from './BaseEvent';
import { Scope } from './types';
export default class WaterfallEvent<Arg> extends BaseEvent<[Arg], Arg> {
export default class WaterfallEvent<Arg, Scope extends string = string> extends BaseEvent<Arg, [Arg], Scope> {
/**

@@ -5,0 +4,0 @@ * Synchronously execute listeners with the defined argument value.

{
"name": "@boost/event",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "A type-safe event system. Designed for Boost applications.",

@@ -21,3 +21,3 @@ "keywords": [

},
"gitHead": "e3e2f99752622b819b547ae28669e8ce3c823f95"
"gitHead": "f442f8eab88834642c44b350f77140bbdbccfa7a"
}
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