emittery
Advanced tools
Comparing version 1.0.0 to 1.0.1
19
index.js
@@ -219,4 +219,6 @@ import {anyMap, producersMap, eventsMap} from './maps.js'; | ||
static get isDebugEnabled() { | ||
// In a browser environment, `globalThis.process` can potentially reference a DOM Element with a `#process` ID, | ||
// so instead of just type checking `globalThis.process`, we need to make sure that `globalThis.process.env` exists. | ||
// eslint-disable-next-line n/prefer-global/process | ||
if (typeof globalThis.process !== 'object') { | ||
if (typeof globalThis.process?.env !== 'object') { | ||
return isGlobalDebugEnabled; | ||
@@ -226,3 +228,3 @@ } | ||
// eslint-disable-next-line n/prefer-global/process | ||
const {env} = globalThis.process || {env: {}}; | ||
const {env} = globalThis.process ?? {env: {}}; | ||
return env.DEBUG === 'emittery' || env.DEBUG === '*' || isGlobalDebugEnabled; | ||
@@ -242,3 +244,3 @@ } | ||
this.debug = options.debug || {}; | ||
this.debug = options.debug ?? {}; | ||
@@ -357,3 +359,3 @@ if (this.debug.enabled === undefined) { | ||
const listeners = getListeners(this, eventName) || new Set(); | ||
const listeners = getListeners(this, eventName) ?? new Set(); | ||
const anyListeners = anyMap.get(this); | ||
@@ -387,3 +389,3 @@ const staticListeners = [...listeners]; | ||
const listeners = getListeners(this, eventName) || new Set(); | ||
const listeners = getListeners(this, eventName) ?? new Set(); | ||
const anyListeners = anyMap.get(this); | ||
@@ -478,4 +480,7 @@ const staticListeners = [...listeners]; | ||
if (typeof eventName === 'string') { | ||
count += anyMap.get(this).size + (getListeners(this, eventName) || new Set()).size | ||
+ (getEventProducers(this, eventName) || new Set()).size + (getEventProducers(this) || new Set()).size; | ||
count += anyMap.get(this).size | ||
+ (getListeners(this, eventName)?.size ?? 0) | ||
+ (getEventProducers(this, eventName)?.size ?? 0) | ||
+ (getEventProducers(this)?.size ?? 0); | ||
continue; | ||
@@ -482,0 +487,0 @@ } |
{ | ||
"name": "emittery", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Simple and modern async event emitter", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
46649
901