chore: ToNostrEventTag.equals
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kieran 2024-05-28 13:09:34 +01:00
parent bc2169a186
commit f2f8b6b225
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 18 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system-react", "name": "@snort/system-react",
"version": "1.3.3", "version": "1.3.5",
"description": "React hooks for @snort/system", "description": "React hooks for @snort/system",
"main": "dist/index.js", "main": "dist/index.js",
"module": "src/index.ts", "module": "src/index.ts",
@ -17,7 +17,7 @@
], ],
"dependencies": { "dependencies": {
"@snort/shared": "^1.0.15", "@snort/shared": "^1.0.15",
"@snort/system": "^1.3.3", "@snort/system": "^1.3.5",
"react": "^18.2.0" "react": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system", "name": "@snort/system",
"version": "1.3.3", "version": "1.3.5",
"description": "Snort nostr system package", "description": "Snort nostr system package",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -17,10 +17,16 @@ import { findTag } from "./utils";
*/ */
export interface ToNostrEventTag { export interface ToNostrEventTag {
toEventTag(): Array<string> | undefined; toEventTag(): Array<string> | undefined;
equals(other: ToNostrEventTag): boolean;
} }
export class NostrHashtagLink implements ToNostrEventTag { 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() { toEventTag() {
return ["t", this.tag]; return ["t", this.tag];
@ -28,7 +34,14 @@ export class NostrHashtagLink implements ToNostrEventTag {
} }
export class UnknownTag 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 { toEventTag(): string[] | undefined {
return this.value; return this.value;
} }