Tweak some typescript things
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type {Event, Filter} from './types'
|
||||
import type {Event} from 'nostr-tools/lib/event'
|
||||
import type {Filter} from 'nostr-tools/lib/filter'
|
||||
import type {Connection} from './Connection'
|
||||
|
||||
export type PublishMeta = {
|
||||
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
import type {Event, Filter} from './types'
|
||||
import type {Event} from 'nostr-tools/lib/event'
|
||||
import type {Filter} from 'nostr-tools/lib/filter'
|
||||
import type {Connection} from './Connection'
|
||||
import type {Emitter} from './util/Emitter'
|
||||
import type {Message} from './util/Socket'
|
||||
@@ -15,7 +16,7 @@ type AuthCallback = (url: string, challenge: string) => void
|
||||
type OkCallback = (url: string, id: string, ...extra: any[]) => void
|
||||
type ErrorCallback = (url: string, id: string, ...extra: any[]) => void
|
||||
type CountCallback = (url: string, ...extra: any[]) => void
|
||||
type SubscribeOpts = {onEvent: EventCallback, onEose: EoseCallback}
|
||||
type SubscribeOpts = {onEvent?: EventCallback, onEose?: EoseCallback}
|
||||
type PublishOpts = {verb: string, onOk: OkCallback, onError: ErrorCallback}
|
||||
type CountOpts = {onCount: CountCallback}
|
||||
type AuthOpts = {onAuth: AuthCallback, onOk: OkCallback}
|
||||
@@ -26,7 +27,7 @@ export class Executor {
|
||||
|
||||
constructor(readonly target: Target) {}
|
||||
|
||||
subscribe(filters: Filter[], {onEvent, onEose}: SubscribeOpts) {
|
||||
subscribe(filters: Filter[], {onEvent, onEose}: SubscribeOpts = {}) {
|
||||
let closed = false
|
||||
|
||||
const id = createSubId('REQ')
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ export class Pool extends Emitter {
|
||||
has(url: string) {
|
||||
return this.data.has(url)
|
||||
}
|
||||
get(url: string, {autoConnect = true, reconnectAfter = 3000} = {}) {
|
||||
get(url: string, {autoConnect = true, reconnectAfter = 3000} = {}): Connection {
|
||||
let connection = this.data.get(url)
|
||||
|
||||
if (autoConnect) {
|
||||
@@ -30,7 +30,7 @@ export class Pool extends Emitter {
|
||||
})
|
||||
}
|
||||
|
||||
return connection
|
||||
return connection!
|
||||
}
|
||||
remove(url: string) {
|
||||
const connection = this.data.get(url)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export type Event = {
|
||||
id: string
|
||||
}
|
||||
|
||||
export type Filter = Record<string, any>
|
||||
Reference in New Issue
Block a user