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

@mirohq/design-system-use-listeners

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mirohq/design-system-use-listeners - npm Package Compare versions

Comparing version 0.1.0-use-press.0 to 0.1.0

19

dist/main.js

@@ -9,12 +9,15 @@ 'use strict';

const globalListeners = react.useRef(/* @__PURE__ */ new Map());
const removeListener = react.useCallback((eventTarget, type, listener, options) => {
var _a;
const fnGlobalListener = (_a = globalListeners.current.get(listener)) == null ? void 0 : _a.fn;
const fn = fnGlobalListener != null ? fnGlobalListener : listener;
eventTarget.removeEventListener(type, fn, options);
globalListeners.current.delete(listener);
}, []);
const removeListener = react.useCallback(
(eventTarget, type, listener, options) => {
var _a;
const fnGlobalListener = (_a = globalListeners.current.get(listener)) == null ? void 0 : _a.fn;
const fn = fnGlobalListener != null ? fnGlobalListener : listener;
eventTarget.removeEventListener(type, fn, options);
globalListeners.current.delete(listener);
},
[]
);
const addListener = react.useCallback(
(eventTarget, type, listener, options) => {
const fn = (options == null ? void 0 : options.once) === true ? (...args) => {
const fn = (typeof options === "object" ? options.once === true : false) ? (...args) => {
listener(...args);

@@ -21,0 +24,0 @@ removeListener(eventTarget, type, listener, options);

@@ -5,12 +5,15 @@ import { useRef, useCallback, useEffect } from 'react';

const globalListeners = useRef(/* @__PURE__ */ new Map());
const removeListener = useCallback((eventTarget, type, listener, options) => {
var _a;
const fnGlobalListener = (_a = globalListeners.current.get(listener)) == null ? void 0 : _a.fn;
const fn = fnGlobalListener != null ? fnGlobalListener : listener;
eventTarget.removeEventListener(type, fn, options);
globalListeners.current.delete(listener);
}, []);
const removeListener = useCallback(
(eventTarget, type, listener, options) => {
var _a;
const fnGlobalListener = (_a = globalListeners.current.get(listener)) == null ? void 0 : _a.fn;
const fn = fnGlobalListener != null ? fnGlobalListener : listener;
eventTarget.removeEventListener(type, fn, options);
globalListeners.current.delete(listener);
},
[]
);
const addListener = useCallback(
(eventTarget, type, listener, options) => {
const fn = (options == null ? void 0 : options.once) === true ? (...args) => {
const fn = (typeof options === "object" ? options.once === true : false) ? (...args) => {
listener(...args);

@@ -17,0 +20,0 @@ removeListener(eventTarget, type, listener, options);

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

declare type Listener = <KW extends keyof WindowEventMap, KH extends keyof HTMLElementEventMap, K extends keyof DocumentEventMap>(element: EventTarget, eventName: KW | KH | K | string, listener: (event: WindowEventMap[KW] | HTMLElementEventMap[KH] | DocumentEventMap[K] | Event) => void, options?: boolean | AddEventListenerOptions) => void;
interface Listeners {
addListener: (<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => void) & ((el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);
removeListener: (<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions) => void) & ((el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
addListener: Listener;
removeListener: Listener;
removeAllListeners: () => void;

@@ -5,0 +6,0 @@ }

{
"name": "@mirohq/design-system-use-listeners",
"version": "0.1.0-use-press.0",
"version": "0.1.0",
"description": "",

@@ -5,0 +5,0 @@ "author": "Miro",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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