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

typed-emitter

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-emitter - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

10

index.d.ts

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

type EventMap = {
export type EventMap = {
[key: string]: (...args: any[]) => void

@@ -11,3 +11,3 @@ }

* ```typescript
* interface MyEvents {
* type MyEvents = {
* error: (error: Error) => void;

@@ -42,10 +42,4 @@ * message: (from: string, content: string) => void;

setMaxListeners (maxListeners: number): this
/**
* required by `FromEvent`
* @see https://github.com/devanshj/rxjs-from-emitter/issues/4#issuecomment-665104646
*/
__events: Events
}
export default TypedEventEmitter
{
"name": "typed-emitter",
"version": "2.0.0",
"version": "2.1.0",
"license": "MIT",

@@ -18,3 +18,6 @@ "description": "Strictly typed event emitter interface for TypeScript 3.",

"rxjs": "*"
},
"devDependencies": {
"rxjs": "^7.5.2"
}
}

4

README.md

@@ -28,3 +28,3 @@ # Typed-Emitter

// Key: Event name; Value: Listener function signature
interface MessageEvents {
type MessageEvents = {
error: (error: Error) => void,

@@ -77,3 +77,3 @@ message: (body: string, from: string) => void

import { fromEvent as rxFromEvent } from "rxjs"
import { FromEvent } from "typed-emitter/rxjs"
import { default as TypedEmitter, FromEvent } from "typed-emitter/rxjs"

@@ -80,0 +80,0 @@ // The `Observable` typing can be correctly inferenced

/**
* devanshj/rxjs-from-emitter#4 - typed-emitter compatibility
*
*
* @see https://github.com/devanshj/rxjs-from-emitter/issues/4#issuecomment-665104646
*/
/* eslint-disable no-use-before-define */
import {
fromEvent as rxFromEvent,
import {
fromEvent as rxFromEvent,
Observable,
} from 'rxjs'
import type TypedEventEmitter from '../index'
import type { default as BaseTypedEmitter, EventMap } from '../index'

@@ -19,8 +19,18 @@ type ObservedValue<A extends unknown[]> =

interface FromTypedEvent {
< Emitter extends TypedEventEmitter<any>
< Emitter extends TypedEmitter<any>
, EventName extends keyof Events
, Events = Emitter extends TypedEventEmitter<infer T> ? T : never
>(emitter: Emitter, event: EventName): Observable<ObservedValue<Events[EventName] extends (...args: infer A) => any ? A : never>>
, Events = Emitter extends TypedEmitter<infer T> ? T : never
>(emitter: Emitter, event: EventName): Observable<ObservedValue<Events[EventName] extends (...args: infer A) => any ? A : never>>
}
export type FromEvent = FromTypedEvent & typeof rxFromEvent
interface TypedEmitter<Events extends EventMap> extends BaseTypedEmitter<Events> {
/**
* required by `FromEvent`
* @see https://github.com/devanshj/rxjs-from-emitter/issues/4#issuecomment-665104646
*/
__events: Events
}
export default TypedEmitter
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