Remove mark methods from tags, move types dependencies to deps
This commit is contained in:
@@ -128,6 +128,9 @@ export const feedsFromTags = (tags: Tags, mappings?: TagFeedMapping[]) => {
|
||||
return feeds
|
||||
}
|
||||
|
||||
export const feedFromTags = (tags: Tags, mappings?: TagFeedMapping[]) =>
|
||||
makeIntersectionFeed(...feedsFromTags(tags, mappings))
|
||||
|
||||
export const feedsFromFilter = ({since, until, ...filter}: Filter) => {
|
||||
const feeds = []
|
||||
|
||||
@@ -150,4 +153,5 @@ export const feedsFromFilter = ({since, until, ...filter}: Filter) => {
|
||||
return feeds
|
||||
}
|
||||
|
||||
export const feedFromFilter = (filter: Filter) => makeIntersectionFeed(...feedsFromFilter(filter))
|
||||
export const feedFromFilter = (filter: Filter) =>
|
||||
makeIntersectionFeed(...feedsFromFilter(filter))
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
"fix": "gts fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/events": "^3.0.3",
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"gts": "^5.0.1",
|
||||
"tsc-multi": "^1.1.0",
|
||||
"typescript": "~5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/events": "^3.0.3",
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"@scure/base": "^1.1.6",
|
||||
"events": "^3.3.0",
|
||||
"throttle-debounce": "^5.0.0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type {Event, Filter} from 'nostr-tools'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {Message} from './Socket'
|
||||
import type {Connection} from './Connection'
|
||||
|
||||
export type PublishMeta = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {Event, Filter} from 'nostr-tools'
|
||||
import type {Emitter} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {Message} from './Socket'
|
||||
import type {Connection} from './Connection'
|
||||
import {NetworkContext} from './Context'
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import WebSocket from "isomorphic-ws"
|
||||
import {Deferred, defer} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
|
||||
export type Message = [string, ...any[]]
|
||||
|
||||
export type PlexMessage = [{relays: string[]}, Message]
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"fix": "gts fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/events": "^3.0.3",
|
||||
"gts": "^5.0.1",
|
||||
"tsc-multi": "^1.1.0",
|
||||
"typescript": "~5.1.6"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Emitter} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {Message} from '../Socket'
|
||||
import type {Target} from '../Executor'
|
||||
|
||||
export class Multi extends Emitter {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {Emitter} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {PlexMessage} from '../Socket'
|
||||
import type {PlexMessage, Message} from '../Socket'
|
||||
import type {Connection} from '../Connection'
|
||||
|
||||
export class Plex extends Emitter {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Emitter} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {Message} from '../Socket'
|
||||
import type {Connection} from '../Connection'
|
||||
|
||||
export class Relay extends Emitter {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Emitter} from '@welshman/lib'
|
||||
import type {Message} from '@welshman/util'
|
||||
import type {Message} from '../Socket'
|
||||
import type {Connection} from '../Connection'
|
||||
|
||||
export class Relays extends Emitter {
|
||||
|
||||
+5
-18
@@ -1,6 +1,6 @@
|
||||
import {EventTemplate} from 'nostr-tools'
|
||||
import type {OmitStatics} from '@welshman/lib'
|
||||
import {Fluent, ensurePlural, last} from '@welshman/lib'
|
||||
import {Fluent, ensurePlural} from '@welshman/lib'
|
||||
import {isShareableRelayUrl, normalizeRelayUrl} from './Relays'
|
||||
import type {Address} from './Address'
|
||||
import {encodeAddress, decodeAddress} from './Address'
|
||||
@@ -23,16 +23,12 @@ export class Tag extends (Fluent<string> as OmitStatics<typeof Fluent<string>, '
|
||||
|
||||
value = () => this.xs[1]
|
||||
|
||||
mark = () => last(this.xs.slice(2))
|
||||
|
||||
entry = () => this.xs.slice(0, 2)
|
||||
|
||||
setKey = (k: string) => this.set(0, k)
|
||||
|
||||
setValue = (v: string) => this.set(1, v)
|
||||
|
||||
setMark = (m: string) => this.xs.length > 2 ? this.set(this.xs.length - 2, m) : this.append(m)
|
||||
|
||||
asAddress = () => decodeAddress(this.value())
|
||||
|
||||
isAddress = (kind?: number) => this.key() === "a" && this.value()?.startsWith(`${kind}:`)
|
||||
@@ -61,20 +57,14 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
|
||||
whereValue = (value: string) => this.filter(t => t.value() === value)
|
||||
|
||||
whereMark = (mark: string) => this.filter(t => t.mark() === mark)
|
||||
|
||||
filterByKey = (keys: string[]) => this.filter(t => keys.includes(t.key()))
|
||||
|
||||
filterByValue = (values: string[]) => this.filter(t => values.includes(t.value()))
|
||||
|
||||
filterByMark = (marks: string[]) => this.filter(t => marks.includes(t.mark()))
|
||||
|
||||
rejectByKey = (keys: string[]) => this.reject(t => keys.includes(t.key()))
|
||||
|
||||
rejectByValue = (values: string[]) => this.reject(t => values.includes(t.value()))
|
||||
|
||||
rejectByMark = (marks: string[]) => this.reject(t => marks.includes(t.mark()))
|
||||
|
||||
get = (key: string) => this.whereKey(key).first()
|
||||
|
||||
keys = () => this.mapTo(t => t.key())
|
||||
@@ -82,8 +72,6 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
values = (key?: string | string[]) =>
|
||||
(key ? this.filterByKey(ensurePlural(key)) : this).mapTo(t => t.value())
|
||||
|
||||
marks = () => this.mapTo(t => t.mark())
|
||||
|
||||
entries = () => this.mapTo(t => t.entry())
|
||||
|
||||
relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(url => normalizeRelayUrl(url))).uniq()
|
||||
@@ -99,15 +87,15 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
|
||||
const dispatchTags = (thisTags: Tags) =>
|
||||
thisTags.forEach((t: Tag, i: number) => {
|
||||
if (t.mark() === 'root') {
|
||||
if (thisTags.whereMark("reply").count() === 0) {
|
||||
if (t.nth(3) === 'root') {
|
||||
if (thisTags.filter(t => t.nth(3) === "reply").count() === 0) {
|
||||
replies.push(t.valueOf())
|
||||
} else {
|
||||
roots.push(t.valueOf())
|
||||
}
|
||||
} else if (t.mark() === 'reply') {
|
||||
} else if (t.nth(3) === 'reply') {
|
||||
replies.push(t.valueOf())
|
||||
} else if (t.mark() === 'mention') {
|
||||
} else if (t.nth(3) === 'mention') {
|
||||
mentions.push(t.valueOf())
|
||||
} else if (i === thisTags.count() - 1) {
|
||||
replies.push(t.valueOf())
|
||||
@@ -220,4 +208,3 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
|
||||
setIMeta = (imeta: Tags[]) => this.removeIMeta().addIMeta(imeta)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"fix": "gts fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/events": "^3.0.3",
|
||||
"gts": "^5.0.1",
|
||||
"tsc-multi": "^1.1.0",
|
||||
"typescript": "~5.1.6"
|
||||
|
||||
Reference in New Issue
Block a user