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

@types/oojs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/oojs - npm Package Compare versions

Comparing version 6.0.1 to 6.0.2

70

oojs/EmitterList.d.ts
declare namespace OO {
interface EmitterListEventMap {
add: [item: EventEmitter, index: number];
clear: [];
move: [item: EventEmitter, index: number, oldIndex: number];
remove: [item: EventEmitter, index: number];
}
/**

@@ -76,2 +83,65 @@ * Contain and manage a list of {@link OO.EventEmitter} items.

clearItems(): this;
// #region Event utils
on<K extends keyof EmitterListEventMap, A extends ArgTuple = [], C = null>(
event: K,
method: EventHandler<C, (this: C, ...args: [...A, ...EmitterListEventMap[K]]) => void>,
args?: A,
context?: C,
): this;
on<K extends string, C = null>(
event: K extends keyof EmitterListEventMap ? never : K,
method: EventHandler<C>,
args?: any[],
context?: C,
): this;
once<K extends keyof EmitterListEventMap>(
event: K,
listener: (this: null, ...args: EmitterListEventMap[K]) => void,
): this;
once<K extends string>(
event: K extends keyof EmitterListEventMap ? never : K,
listener: (this: null, ...args: any[]) => void,
): this;
off<K extends keyof EmitterListEventMap, C = null>(
event: K,
method?: EventHandler<C, (this: C, ...args: EmitterListEventMap[K]) => void>,
context?: C,
): this;
off<K extends string, C = null>(
event: K extends keyof EmitterListEventMap ? never : K,
method?: EventHandler<C>,
context?: C,
): this;
emit<K extends keyof EmitterListEventMap>(event: K, ...args: EmitterListEventMap[K]): boolean;
emit<K extends string>(event: K extends keyof EmitterListEventMap ? never : K, ...args: any[]): boolean;
emitThrow<K extends keyof EmitterListEventMap>(event: K, ...args: EmitterListEventMap[K]): boolean;
emitThrow<K extends string>(event: K extends keyof EmitterListEventMap ? never : K, ...args: any[]): boolean;
connect<T extends Partial<Record<keyof EmitterListEventMap, any>>, C>(
context: C,
methods: {
[K in keyof T]: EventConnectionMapEntry<
C,
K extends keyof EmitterListEventMap ? EmitterListEventMap[K] : any[],
T[K]
>;
},
): this;
disconnect<T extends Partial<Record<keyof EmitterListEventMap, any>>, C>(
context: C,
methods?: {
[K in keyof T]: EventConnectionMapEntry<
C,
K extends keyof EmitterListEventMap ? EmitterListEventMap[K] : any[],
T[K]
>;
},
): this;
// #endregion
}

@@ -78,0 +148,0 @@

38

oojs/EventEmitter.d.ts

@@ -15,19 +15,5 @@ declare namespace OO {

*/
on<C = null>(event: string, method: (this: C, ...args: any[]) => void, args?: any[], context?: C): this;
on<C = null>(event: string, method: EventHandler<C>, args?: any[], context?: C): this;
/**
* Add a listener to events of a specific event.
*
* The listener can be a function or the string name of a method; if the latter, then the
* name lookup happens at the time the listener is called.
*
* @param event Type of event to listen to
* @param method Function or method name to call when event occurs
* @param args Arguments to pass to listener, will be prepended to emitted arguments
* @param context Context object for function or method call
* @throws {Error} Listener argument is not a function or a valid method name
*/
on<C extends object>(event: string, method: ExtractFunctionKeys<C>, args: any[], context: C): this;
/**
* Add a one-time listener to a specific event.

@@ -45,7 +31,7 @@ *

* @param method Listener to remove. Must be in the same form as was passed
* to "on". Omit to remove all listeners.
* to "{@link on}". Omit to remove all listeners.
* @param context Context object function or method call
* @throws {Error} Listener argument is not a function or a valid method name
*/
off(event: string, method?: string | ((...args: any[]) => void), context?: any): this;
off<C = null>(event: string, method?: EventHandler<C>, context?: C): this;

@@ -98,11 +84,3 @@ /**

*/
connect<C>(
context: C,
methods: Record<
string,
| ((this: C, ...args: any[]) => void)
| (C extends object ? ExtractFunctionKeys<C> : never)
| [((this: C, ...args: any[]) => void) | (C extends object ? ExtractFunctionKeys<C> : never), ...any[]]
>,
): this;
connect<C>(context: C, methods: Record<string, EventHandler<C> | [EventHandler<C>, ...any[]]>): this;

@@ -122,9 +100,3 @@ /**

*/
disconnect(
context: any,
methods?: Record<
string,
string | ((...args: any[]) => void) | [((...args: any[]) => void) | string, ...any[]]
>,
): this;
disconnect<C>(context: C, methods?: Record<string, EventHandler<C> | [EventHandler<C>, ...any[]]>): this;
}

@@ -131,0 +103,0 @@

{
"name": "@types/oojs",
"version": "6.0.1",
"version": "6.0.2",
"description": "TypeScript definitions for OOjs",

@@ -23,4 +23,4 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/oojs",

"dependencies": {},
"typesPublisherContentHash": "4bb60823876d124163ec320f1b83263018cb7ba8aab9e48929e2faed570ee2b0",
"typesPublisherContentHash": "458f17ea63492569f9da57746e859435e2a87adb9fbabb1050cee61f61fca799",
"typeScriptVersion": "4.2"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Wed, 23 Nov 2022 18:11:54 GMT
* Last updated: Mon, 05 Dec 2022 22:33:08 GMT
* Dependencies: none

@@ -14,0 +14,0 @@ * Global values: `OO`

declare namespace OO {
interface RegistryEventMap {
register: [name: string, data: unknown];
unregister: [name: string, data: unknown];
}
/**

@@ -37,2 +42,65 @@ * A map interface for associating arbitrary data with a symbolic name. Used in

lookup(name: string): unknown | undefined;
// #region Event utils
on<K extends keyof RegistryEventMap, A extends ArgTuple = [], C = null>(
event: K,
method: EventHandler<C, (this: C, ...args: [...A, ...RegistryEventMap[K]]) => void>,
args?: A,
context?: C,
): this;
on<K extends string, C = null>(
event: K extends keyof RegistryEventMap ? never : K,
method: EventHandler<C>,
args?: any[],
context?: C,
): this;
once<K extends keyof RegistryEventMap>(
event: K,
listener: (this: null, ...args: RegistryEventMap[K]) => void,
): this;
once<K extends string>(
event: K extends keyof RegistryEventMap ? never : K,
listener: (this: null, ...args: any[]) => void,
): this;
off<K extends keyof RegistryEventMap, C = null>(
event: K,
method?: EventHandler<C, (this: C, ...args: RegistryEventMap[K]) => void>,
context?: C,
): this;
off<K extends string, C = null>(
event: K extends keyof RegistryEventMap ? never : K,
method?: EventHandler<C>,
context?: C,
): this;
emit<K extends keyof RegistryEventMap>(event: K, ...args: RegistryEventMap[K]): boolean;
emit<K extends string>(event: K extends keyof RegistryEventMap ? never : K, ...args: any[]): boolean;
emitThrow<K extends keyof RegistryEventMap>(event: K, ...args: RegistryEventMap[K]): boolean;
emitThrow<K extends string>(event: K extends keyof RegistryEventMap ? never : K, ...args: any[]): boolean;
connect<T extends Partial<Record<keyof RegistryEventMap, any>>, C>(
context: C,
methods: {
[K in keyof T]: EventConnectionMapEntry<
C,
K extends keyof RegistryEventMap ? RegistryEventMap[K] : any[],
T[K]
>;
},
): this;
disconnect<T extends Partial<Record<keyof RegistryEventMap, any>>, C>(
context: C,
methods?: {
[K in keyof T]: EventConnectionMapEntry<
C,
K extends keyof RegistryEventMap ? RegistryEventMap[K] : any[],
T[K]
>;
},
): this;
// #endregion
}

@@ -39,0 +107,0 @@

@@ -59,4 +59,4 @@ declare namespace OO {

type CheckFunctionType<T, K extends keyof T> = K extends any
? T[K] extends (...args: any[]) => any
type FunctionFieldsOf<T, F extends (...args: any[]) => any, K extends keyof T = keyof T> = K extends any
? T[K] extends F
? K

@@ -66,3 +66,11 @@ : never

type ExtractFunctionKeys<T extends object> = Exclude<CheckFunctionType<T, keyof T>, never>;
type EventHandler<C, F extends (...args: any[]) => any = (this: C, ...args: any[]) => void> =
| FunctionFieldsOf<C, F>
| F;
type ArgTuple = [] | [any] | [any, any] | [any, any, any] | [any, any, any, any] | [any, any, any, any, any];
type EventConnectionMapEntry<C, P extends any[], T> = T extends ArgTuple
? [EventHandler<C, (this: C, ...args: [...T, ...P]) => void>, ...T]
: EventHandler<C, (this: C, ...args: P) => void>;
}
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