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

publisher-subscriber-pattern

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

publisher-subscriber-pattern - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

3

CHANGELOG.MD

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

# @2.0.3 [author: Katarzyna Ziomek-Zdanowicz, date: 2019.09.09]
* adds Window to EmitterInstance type
# @2.0.2 [author: Katarzyna Ziomek-Zdanowicz, date: 2019.09.08]

@@ -2,0 +5,0 @@ * converts EventCallback to generic type so type React.Events can be used

2

package.json
{
"name": "publisher-subscriber-pattern",
"version": "2.0.2",
"version": "2.0.3",
"description": "Publisher subscriber pattern that can be used with different event emitters including browser window",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import { Subscriber } from './subscriber';
// generic type so type React.Events can be used
// EventCallback is generic, thus generic type of Event can be used (e.g. type React.Events )
export type EventCallback<P = {}> = (event: P & Event) => void;

@@ -8,3 +8,3 @@

export type EventData = [EventCallback, Subscriber[]];
export type EmitterInstance = Record<string | number | symbol, unknown>;
export type EmitterInstance = Record<string | number | symbol, unknown> | Window;

@@ -22,4 +22,10 @@ export type SubscriptionFunctions = (eventName: string, eventCallback: EventCallback) => void;

if (emitterInstance instanceof Window) {
return (
addListenerMethodName in emitterInstance &&
removeListenerMethodName in emitterInstance
);
}
const isOfType = (value: unknown, type: 'symbol' | 'function'): boolean => typeof value === type;
const addMethodName: keyof typeof emitterInstance = addListenerMethodName;

@@ -26,0 +32,0 @@ const removeMethodName: keyof typeof emitterInstance = removeListenerMethodName;

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