Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(sequences).forEach(fullHexcode => {
const hexcode = stripHexcode(fullHexcode);
const emoji = sequences[fullHexcode];
const tags: string[] = extractField(hexcode, 'tags') || [];
let annotation: string = extractField(hexcode, 'annotation') || '';
// Use the localized territory name
if (hasProperty(emoji.property, ['Emoji_Flag_Sequence'])) {
const countryCode = fullHexcode
.split('-')
.map((hex: string) => REGIONAL_INDICATORS[hex])
.join('');
if (!annotation) {
annotation = localization.territories[countryCode];
}
tags.push(countryCode);
if ('tone' in baseEmoji && baseEmoji.tone !== null) {
emoji.tone = baseEmoji.tone;
}
// Presentation variations
if ('variations' in baseEmoji) {
emoji.emoji = toUnicode(baseEmoji.variations!.emoji);
emoji.text = toUnicode(baseEmoji.variations!.text);
}
if ('emoticon' in baseEmoji) {
emoji.emoticon = baseEmoji.emoticon;
}
// Annotations
const annotation = annotations[stripHexcode(emoji.hexcode)]; // No ZWJ, selectors
if (annotation) {
if (annotation.annotation) {
emoji.annotation = annotation.annotation;
}
if (annotation.tags && annotation.tags.length > 0) {
emoji.tags = annotation.tags;
// Sort the tags for easier diffs
emoji.tags.sort();
// Some locales duplicate the annotation in the tag list
if (emoji.tags.length > 1) {
emoji.tags = emoji.tags.filter((tag: string) => tag !== emoji.annotation);
}
emoji.skins = Object.values(baseEmoji.modifications!).map(mod => {
const skin = createEmoji(mod, versions, annotations);
skin.annotation = (annotations[stripHexcode(skin.hexcode)] || {}).annotation || '';
skin.shortcodes = (emoji.shortcodes || []).map(
code => `${code}_tone${Array.isArray(skin.tone) ? skin.tone.join('-') : skin.tone}`,
);
// Remove any tags
delete skin.tags;
return skin;
});
}
emojiCDN: (hexcode, large) =>
`https://cdn.jsdelivr.net/emojione/assets/4.5/png/${large ? 64 : 32}/${stripHexcode(
hexcode,
).toLowerCase()}.png`,
logger: console.log,