mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-10 04:06:27 +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(',');
|
||||
};
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
const _JSON = JSON;
|
||||
|
||||
const COLONS_REGEX = /^(?::([^:]+):)(?::skin-tone-(\d):)?$/;
|
||||
const SKINS = ['1F3FA', '1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
|
||||
|
||||
// @ts-expect-error
|
||||
function unifiedToNative(unified) {
|
||||
let unicodes = unified.split('-'),
|
||||
// @ts-expect-error
|
||||
codePoints = unicodes.map((u) => `0x${u}`);
|
||||
function unifiedToNative(unified: Emoji['unified']) {
|
||||
const unicodes = unified?.split('-') ?? [];
|
||||
const codePoints = unicodes.map((u) => +`0x${u}`);
|
||||
|
||||
return String.fromCodePoint(...codePoints);
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
// @ts-expect-error
|
||||
function sanitize(emoji) {
|
||||
let {
|
||||
|
Loading…
x
Reference in New Issue
Block a user