Use Reflect.has instead of Object.hasOwn

This commit is contained in:
hzrd149 2024-12-04 10:34:39 -06:00
parent c207344ddc
commit 55ba373d4b
5 changed files with 393 additions and 402 deletions

View File

@ -27,13 +27,13 @@
"@chakra-ui/theme-tools": "^2.2.6",
"@codemirror/autocomplete": "^6.18.3",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/language": "^6.10.5",
"@codemirror/language": "^6.10.6",
"@codemirror/view": "^6.35.0",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@getalby/bitcoin-connect": "^3.6.2",
"@getalby/bitcoin-connect-react": "^3.6.2",
"@noble/ciphers": "^1.1.2",
"@getalby/bitcoin-connect": "^3.6.3",
"@getalby/bitcoin-connect-react": "^3.6.3",
"@noble/ciphers": "^1.1.3",
"@noble/curves": "^1.7.0",
"@noble/hashes": "^1.6.1",
"@noble/secp256k1": "^1.7.1",
@ -54,7 +54,7 @@
"blossom-drive-sdk": "^0.4.1",
"blurhash": "^2.0.5",
"canvas-confetti": "^1.9.3",
"chart.js": "^4.4.6",
"chart.js": "^4.4.7",
"cheerio": "^1.0.0",
"chroma-js": "^2.6.0",
"codemirror": "^6.0.1",
@ -83,7 +83,7 @@
"nostr-idb": "^2.2.0",
"nostr-tools": "^2.10.4",
"nostr-wasm": "^0.1.0",
"prettier": "^3.4.1",
"prettier": "^3.4.2",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"react-diff-viewer-continued": "^3.4.0",
@ -142,7 +142,7 @@
"eventemitter3": "^5.0.1",
"typescript": "^5.7.2",
"vite": "^5.4.11",
"vite-plugin-pwa": "^0.21.0",
"vite-plugin-pwa": "^0.21.1",
"workbox-build": "^7.3.0",
"workbox-window": "^7.3.0"
},

769
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,10 @@ export type PeopleToken = { pubkey: string; names: string[] };
type Token = Emoji | PeopleToken;
function isEmojiToken(token: Token): token is Emoji {
return Object.hasOwn(token, "char");
return Reflect.has(token, "char");
}
function isPersonToken(token: Token): token is PeopleToken {
return Object.hasOwn(token, "pubkey");
return Reflect.has(token, "pubkey");
}
const Item = ({ entity }: ItemComponentProps<Token>) => {

View File

@ -21,13 +21,13 @@ export function isReplaceable(kind: number) {
export function pointerMatchEvent(event: NostrEvent, pointer: AddressPointer | EventPointer) {
if (isReplaceable(event.kind)) {
if (Object.hasOwn(pointer, "pubkey")) {
if (Reflect.has(pointer, "pubkey")) {
const p = pointer as AddressPointer;
const d = event.tags.find(isDTag)?.[1];
return event.pubkey === p.pubkey && event.kind === p.kind && d === p.identifier;
}
} else {
if (Object.hasOwn(pointer, "id")) {
if (Reflect.has(pointer, "id")) {
const p = pointer as EventPointer;
return p.id === event.id;
}

View File

@ -109,10 +109,10 @@ export default function PublishProvider({ children }: PropsWithChildren) {
}
// add pubkey to event
if (!Object.hasOwn(event, "pubkey")) event = await finalizeDraft(event);
if (!Reflect.has(event, "pubkey")) event = await finalizeDraft(event);
// sign event
const signed = !Object.hasOwn(event, "sig") ? await requestSignature(event) : (event as NostrEvent);
const signed = !Reflect.has(event, "sig") ? await requestSignature(event) : (event as NostrEvent);
const pub = new PublishAction(label, relays, signed);
setLog((arr) => arr.concat(pub));