Separate general purpose utils and protocol-related utils

This commit is contained in:
Jon Staab
2024-03-25 10:38:16 -07:00
parent bb983d8207
commit 74b926e227
20 changed files with 39 additions and 13 deletions
+3 -3
View File
@@ -2,9 +2,9 @@ import EventEmitter from "events"
import type {Event} from 'nostr-tools' import type {Event} from 'nostr-tools'
import type {Executor} from "./Executor" import type {Executor} from "./Executor"
import type {Connection} from './Connection' import type {Connection} from './Connection'
import type {Filter} from '../util/Filters' import type {Filter} from '../protocol/Filters'
import {matchFilters} from "../util/Filters" import {matchFilters} from "../protocol/Filters"
import {hasValidSignature} from "../util/Events" import {hasValidSignature} from "../protocol/Events"
export type SubscriptionOpts = { export type SubscriptionOpts = {
executor: Executor executor: Executor
+23
View File
@@ -0,0 +1,23 @@
export * from "./connect/Connection"
export * from "./connect/ConnectionMeta"
export * from "./connect/Executor"
export * from "./connect/Pool"
export * from "./connect/Socket"
export * from "./connect/Subscription"
export * from "./connect/target/Multi"
export * from "./connect/target/Plex"
export * from "./connect/target/Relay"
export * from "./connect/target/Relays"
export * from "./protocol/Address"
export * from "./util/Deferred"
export * from "./util/Emitter"
export * from "./protocol/Events"
export * from "./protocol/Filters"
export * from "./util/Fluent"
export * from "./protocol/Kinds"
export * from "./util/LRUCache"
export * from "./util/Queue"
export * from "./protocol/Relays"
export * from "./protocol/Router"
export * from "./protocol/Tags"
export * from "./util/Tools"
+7
View File
@@ -0,0 +1,7 @@
export * from './Deferred'
export * from './Emitter'
export * from './Fluent'
export * from './LRUCache'
export * from './Queue'
export * from './Tools'
export {default as normalizeUrl} from './normalize-url'
@@ -1,7 +1,6 @@
import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools' import type {Event, EventTemplate, UnsignedEvent} from 'nostr-tools'
import {verifyEvent, getEventHash} from 'nostr-tools' import {verifyEvent, getEventHash} from 'nostr-tools'
import {cached} from "./LRUCache" import {cached, now} from "../util"
import {now} from './Tools'
import {Tags} from './Tags' import {Tags} from './Tags'
import {addressFromEvent, encodeAddress} from './Address' import {addressFromEvent, encodeAddress} from './Address'
import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds' import {isEphemeralKind, isReplaceableKind, isPlainReplaceableKind, isParameterizedReplaceableKind} from './Kinds'
+1 -1
View File
@@ -1,4 +1,4 @@
import {between} from './Tools' import {between} from '../util'
export const isEphemeralKind = (kind: number) => between(19999, 29999, kind) export const isEphemeralKind = (kind: number) => between(19999, 29999, kind)
@@ -1,5 +1,4 @@
import normalizeUrl from "./normalize-url" import {normalizeUrl, stripProtocol} from "../util"
import {stripProtocol} from './Tools'
export const isShareableRelayUrl = (url: string) => export const isShareableRelayUrl = (url: string) =>
Boolean( Boolean(
@@ -1,8 +1,8 @@
import type {EventTemplate, UnsignedEvent} from 'nostr-tools' import type {EventTemplate, UnsignedEvent} from 'nostr-tools'
import {first, uniq, shuffle} from '../util'
import type {Rumor} from './Events' import type {Rumor} from './Events'
import {getAddress, isReplaceable} from './Events' import {getAddress, isReplaceable} from './Events'
import {Tag, Tags} from './Tags' import {Tag, Tags} from './Tags'
import {first, uniq, shuffle} from './Tools'
import {GROUP_DEFINITION, COMMUNITY_DEFINITION} from './Kinds' import {GROUP_DEFINITION, COMMUNITY_DEFINITION} from './Kinds'
import {addressFromEvent, decodeAddress} from './Address' import {addressFromEvent, decodeAddress} from './Address'
+2 -3
View File
@@ -1,7 +1,6 @@
import {EventTemplate} from 'nostr-tools' import {EventTemplate} from 'nostr-tools'
import {Fluent} from './Fluent' import type {OmitStatics} from '../util'
import type {OmitStatics} from './Tools' import {Fluent, last} from '../util'
import {last} from './Tools'
import {isShareableRelayUrl, normalizeRelayUrl} from './Relays' import {isShareableRelayUrl, normalizeRelayUrl} from './Relays'
import type {Address} from './Address' import type {Address} from './Address'
import {encodeAddress, decodeAddress} from './Address' import {encodeAddress, decodeAddress} from './Address'
-1
View File
@@ -1,6 +1,5 @@
{ {
"targets": [ "targets": [
{"extname": ".cjs", "module": "commonjs"},
{"extname": ".mjs", "module": "esnext", "moduleResolution": "node"} {"extname": ".mjs", "module": "esnext", "moduleResolution": "node"}
], ],
"projects": ["tsconfig.json"] "projects": ["tsconfig.json"]