pinafore/src/routes/_utils/removeEmoji.js
Nolan Lawson 16e66346d7
fix!: remove esm package, use native Node ES modules (#2064)
BREAKING CHANGE: Node v12.20+, v14.14+, or v16.0+ is required

* fix!: remove esm package, use native Node ES modules

* fix: fix some CJS imports
2021-07-04 20:19:04 -07:00

14 lines
406 B
JavaScript

import { replaceAll } from './strings.js'
import { replaceEmoji } from './replaceEmoji.js'
export function removeEmoji (text, emojis) {
// remove custom emoji
if (emojis) {
for (const emoji of emojis) {
const shortcodeWithColons = `:${emoji.shortcode}:`
text = replaceAll(text, shortcodeWithColons, '')
}
}
// remove native emoji
return replaceEmoji(text, () => '').trim()
}