mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-10 12:16:23 +01:00
Refactor unifiedToNative function in emoji_utils
The unifiedToNative function in emoji_utils.ts has been refactored for cleaner coding practices. Lint disabling has been moved to a different part of the code, and type checking has been revised to specify that the input unified is of type Emoji['unified']. The function's variables have been updated to const for better securities against undesired changes.
This commit is contained in:
parent
77a0621ecc
commit
562c8778fb
@ -34,22 +34,20 @@ const buildSearch = (data: Data) => {
|
|||||||
return search.join(',');
|
return search.join(',');
|
||||||
};
|
};
|
||||||
|
|
||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
const _JSON = JSON;
|
const _JSON = JSON;
|
||||||
|
|
||||||
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
|
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
|
||||||
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
||||||
|
|
||||||
// @ts-expect-error
|
function unifiedToNative(unified: Emoji['unified']) {
|
||||||
function unifiedToNative(unified) {
|
const unicodes = unified?.split('-') ?? [];
|
||||||
let unicodes = unified.split('-'),
|
const codePoints = unicodes.map((u) => +`0x${u}`);
|
||||||
// @ts-expect-error
|
|
||||||
codePoints = unicodes.map((u) => `0x${u}`);
|
|
||||||
|
|
||||||
return String.fromCodePoint(...codePoints);
|
return String.fromCodePoint(...codePoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
function sanitize(emoji) {
|
function sanitize(emoji) {
|
||||||
let {
|
let {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user