diff --git a/nip06.test.ts b/nip06.test.ts index 4e1a2f1..c788284 100644 --- a/nip06.test.ts +++ b/nip06.test.ts @@ -9,9 +9,7 @@ test('generate private key from a mnemonic', async () => { test('generate private key for account 1 from a mnemonic', async () => { const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong' const privateKey = privateKeyFromSeedWords(mnemonic, undefined, 1) - expect(privateKey).toEqual( - 'b5fc7f229de3fb5c189063e3b3fc6c921d8f4366cff5bd31c6f063493665eb2b' - ) + expect(privateKey).toEqual('b5fc7f229de3fb5c189063e3b3fc6c921d8f4366cff5bd31c6f063493665eb2b') }) test('generate private key from a mnemonic and passphrase', async () => { @@ -25,7 +23,5 @@ test('generate private key for account 1 from a mnemonic and passphrase', async const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong' const passphrase = '123' const privateKey = privateKeyFromSeedWords(mnemonic, passphrase, 1) - expect(privateKey).toEqual( - '2e0f7bd9e3c3ebcdff1a90fb49c913477e7c055eba1a415d571b6a8c714c7135' - ) + expect(privateKey).toEqual('2e0f7bd9e3c3ebcdff1a90fb49c913477e7c055eba1a415d571b6a8c714c7135') }) diff --git a/nip06.ts b/nip06.ts index da30258..9a80253 100644 --- a/nip06.ts +++ b/nip06.ts @@ -3,11 +3,7 @@ import { wordlist } from '@scure/bip39/wordlists/english' import { generateMnemonic, mnemonicToSeedSync, validateMnemonic } from '@scure/bip39' import { HDKey } from '@scure/bip32' -export function privateKeyFromSeedWords( - mnemonic: string, - passphrase?: string, - accountIndex = 0 -): string { +export function privateKeyFromSeedWords(mnemonic: string, passphrase?: string, accountIndex = 0): string { let root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase)) let privateKey = root.derive(`m/44'/1237'/${accountIndex}'/0/0`).privateKey if (!privateKey) throw new Error('could not derive private key') diff --git a/nip19.ts b/nip19.ts index 14ef66c..d817865 100644 --- a/nip19.ts +++ b/nip19.ts @@ -189,7 +189,7 @@ export function nprofileEncode(profile: ProfilePointer): `nprofile1${string}` { export function neventEncode(event: EventPointer): `nevent1${string}` { let kindArray - if (event.kind != undefined) { + if (event.kind !== undefined) { kindArray = integerToUint8Array(event.kind) } diff --git a/nip27.ts b/nip27.ts index f8a6d3b..c63804b 100644 --- a/nip27.ts +++ b/nip27.ts @@ -13,7 +13,7 @@ export interface NostrURIMatch extends NostrURI { } /** Find and decode all NIP-21 URIs. */ -export function * matchAll(content: string): Iterable { +export function* matchAll(content: string): Iterable { const matches = content.matchAll(regex()) for (const match of matches) { diff --git a/nip30.test.ts b/nip30.test.ts index cc7809f..395828c 100644 --- a/nip30.test.ts +++ b/nip30.test.ts @@ -1,4 +1,4 @@ -import {matchAll, replaceAll} from './nip30.ts' +import { matchAll, replaceAll } from './nip30.ts' test('matchAll', () => { const result = matchAll('Hello :blobcat: :disputed: ::joy:joy:') @@ -8,21 +8,21 @@ test('matchAll', () => { name: 'blobcat', shortcode: ':blobcat:', start: 6, - end: 15 + end: 15, }, { name: 'disputed', shortcode: ':disputed:', start: 16, - end: 26 - } + end: 26, + }, ]) }) test('replaceAll', () => { const content = 'Hello :blobcat: :disputed: ::joy:joy:' - const result = replaceAll(content, ({name}) => { + const result = replaceAll(content, ({ name }) => { return `` }) diff --git a/nip30.ts b/nip30.ts index 8465c85..9030c73 100644 --- a/nip30.ts +++ b/nip30.ts @@ -21,7 +21,7 @@ export interface CustomEmojiMatch extends CustomEmoji { } /** Find all custom emoji shortcodes. */ -export function * matchAll(content: string): Iterable { +export function* matchAll(content: string): Iterable { const matches = content.matchAll(regex()) for (const match of matches) { @@ -32,7 +32,7 @@ export function * matchAll(content: string): Iterable { shortcode: shortcode as `:${string}:`, name, start: match.index!, - end: match.index! + shortcode.length + end: match.index! + shortcode.length, } } catch (_e) { // do nothing @@ -41,10 +41,7 @@ export function * matchAll(content: string): Iterable { } /** Replace all emoji shortcodes in the content. */ -export function replaceAll( - content: string, - replacer: (match: CustomEmoji) => string -): string { +export function replaceAll(content: string, replacer: (match: CustomEmoji) => string): string { return content.replaceAll(regex(), (shortcode, name) => { return replacer({ shortcode: shortcode as `:${string}:`,