Socket
Socket
Sign inDemoInstall

@lite-v3/common-helpers

Package Overview
Dependencies
0
Maintainers
7
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

14

dist/emitter/index.d.ts
/**
* This is a simpler version of `Record<T, U>` which do not rely
* on index type checks to determine whether a type is an object
* or not. Unlike the `object` type, this has an additional checks
* to exclude `Array<T>`, and are intended to be used in an `extends` clause.
*/
declare type AnyRecord<T> = any[] extends T ? never : object;
/**
*

@@ -29,3 +36,2 @@ * @see https://github.com/developit/mitt

*/
export declare type EventType = string | symbol;
export declare type Handler<T = unknown> = (event: T) => void;

@@ -35,4 +41,4 @@ export declare type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void;

export declare type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
export declare type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
export interface Emitter<Events extends Record<EventType, unknown>> {
export declare type EventHandlerMap<Events extends AnyRecord<Events>> = Map<keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
export interface Emitter<Events extends AnyRecord<Events>> {
all: EventHandlerMap<Events>;

@@ -46,3 +52,3 @@ on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;

}
declare function mitt<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): Emitter<Events>;
declare function mitt<Events extends AnyRecord<Events>>(all?: EventHandlerMap<Events>): Emitter<Events>;
export default mitt;

@@ -57,2 +57,7 @@ "use strict";

handlers.slice().forEach(function(handler) {
/**
* This is valid since, although `evt` may be optional, from our
* function overload it will map only to `undefined` while kept
* enforcing the other types to be required.
*/ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
handler(evt);

@@ -64,2 +69,7 @@ });

handlers.slice().forEach(function(handler) {
/**
* This is valid since, although `evt` may be optional, from our
* function overload it will map only to `undefined` while kept
* enforcing the other types to be required.
*/ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
handler(type, evt);

@@ -66,0 +76,0 @@ });

{
"name": "@lite-v3/common-helpers",
"version": "0.1.1",
"version": "0.1.2",
"description": "Public common helpers for Tokopedia Web",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc