prettify and lint.

This commit is contained in:
fiatjaf
2023-12-16 12:39:24 -03:00
parent 0108e3b605
commit d16f3f77c3
6 changed files with 13 additions and 24 deletions

View File

@@ -21,7 +21,7 @@ export interface CustomEmojiMatch extends CustomEmoji {
}
/** Find all custom emoji shortcodes. */
export function * matchAll(content: string): Iterable<CustomEmojiMatch> {
export function* matchAll(content: string): Iterable<CustomEmojiMatch> {
const matches = content.matchAll(regex())
for (const match of matches) {
@@ -32,7 +32,7 @@ export function * matchAll(content: string): Iterable<CustomEmojiMatch> {
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<CustomEmojiMatch> {
}
/** 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}:`,