mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-18 00:55:35 +00:00
use interface instead of type
This commit is contained in:
parent
2603291203
commit
2603292a0e
3 changed files with 5 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { EventEmitter } from 'node:events'
|
||||
import type { EmitterLike } from './index.ts'
|
||||
|
||||
export default function defaultEmitter() {
|
||||
export default function defaultEmitter(): EmitterLike {
|
||||
return new EventEmitter()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import redisEmitter from './redis-emitter.ts'
|
|||
|
||||
type Listener = (...args: unknown[]) => void
|
||||
|
||||
export type EmitterLike = {
|
||||
export interface EmitterLike {
|
||||
on: (eventName: string, handler: Listener) => unknown
|
||||
once: (eventName: string, handler: Listener) => unknown
|
||||
off?: (eventName: string, handler: Listener) => unknown
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { EventEmitter } from 'node:events'
|
|||
import safeStringify from 'fast-safe-stringify'
|
||||
import type { Redis } from 'ioredis'
|
||||
import * as logger from '../logger.ts'
|
||||
import type { EmitterLike } from './index.ts'
|
||||
|
||||
function replacer(key: string, value: unknown): unknown {
|
||||
// Remove the circular structure and internal ones
|
||||
|
|
@ -19,7 +20,7 @@ function replacer(key: string, value: unknown): unknown {
|
|||
export default function redisEmitter(
|
||||
redisClient: Redis,
|
||||
redisPubSubScope?: string,
|
||||
) {
|
||||
): EmitterLike {
|
||||
const prefix = redisPubSubScope ? `${redisPubSubScope}:` : ''
|
||||
const getPrefixedEventName = (eventName: string) => `${prefix}${eventName}`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue