nostr-tools/helpers.ts

17 lines
523 B
TypeScript

import { verifiedSymbol, type Event, type Nostr } from './core.ts'
export async function yieldThread() {
return new Promise(resolve => {
const ch = new MessageChannel()
// @ts-ignore (typescript thinks this property should be called `addListener`, but in fact it's `addEventListener`)
ch.port1.addEventListener('message', resolve)
ch.port2.postMessage(0)
ch.port1.start()
})
}
export const alwaysTrue: Nostr['verifyEvent'] = (t: Event) => {
t[verifiedSymbol] = true
return t[verifiedSymbol]
}