chore: ToNostrEventTag.equals
This commit is contained in:
parent
bc2169a186
commit
f2f8b6b225
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system-react",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.5",
|
||||
"description": "React hooks for @snort/system",
|
||||
"main": "dist/index.js",
|
||||
"module": "src/index.ts",
|
||||
@ -17,7 +17,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@snort/shared": "^1.0.15",
|
||||
"@snort/system": "^1.3.3",
|
||||
"@snort/system": "^1.3.5",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system",
|
||||
"version": "1.3.3",
|
||||
"version": "1.3.5",
|
||||
"description": "Snort nostr system package",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
@ -17,10 +17,16 @@ import { findTag } from "./utils";
|
||||
*/
|
||||
export interface ToNostrEventTag {
|
||||
toEventTag(): Array<string> | undefined;
|
||||
equals(other: ToNostrEventTag): boolean;
|
||||
}
|
||||
|
||||
export class NostrHashtagLink implements ToNostrEventTag {
|
||||
constructor(readonly tag: string) {}
|
||||
constructor(readonly tag: string) { }
|
||||
|
||||
equals(other: ToNostrEventTag): boolean {
|
||||
const otherTag = other.toEventTag();
|
||||
return otherTag?.at(0) === "t" && otherTag?.at(1) === this.tag;
|
||||
}
|
||||
|
||||
toEventTag() {
|
||||
return ["t", this.tag];
|
||||
@ -28,7 +34,14 @@ export class NostrHashtagLink implements ToNostrEventTag {
|
||||
}
|
||||
|
||||
export class UnknownTag implements ToNostrEventTag {
|
||||
constructor(readonly value: Array<string>) {}
|
||||
constructor(readonly value: Array<string>) { }
|
||||
|
||||
equals(other: ToNostrEventTag): boolean {
|
||||
const otherTag = other.toEventTag();
|
||||
return otherTag?.at(0) === this.value.at(0) &&
|
||||
otherTag?.at(1) === this.value.at(1)
|
||||
}
|
||||
|
||||
toEventTag(): string[] | undefined {
|
||||
return this.value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user