Tweak some typescript things

This commit is contained in:
Jonathan Staab
2023-09-20 10:28:15 -07:00
parent 7c9039704c
commit 25adcc71ef
9 changed files with 689 additions and 39 deletions
+2 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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)
-5
View File
@@ -1,5 +0,0 @@
export type Event = {
id: string
}
export type Filter = Record<string, any>