How to use the emoji-datasource.map function in emoji-datasource

To help you get started, we’ve selected a few emoji-datasource examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joeattardi / svelte-emoji-selector / scripts / processEmojiData.js View on Github external
const { writeFileSync } = require('fs');

const rawData = require('emoji-datasource');

function getEmoji(unified) {
  const chars = unified.split('-');
  const codePoints = chars.map(char => parseInt(char, 16));
  return String.fromCodePoint(...codePoints);
}

rawData.sort((e1, e2) => e1.sort_order - e2.sort_order);
const newEmojiData = rawData.map(emojiItem => {
  const newData = {
    name: emojiItem.short_name,
    key: emojiItem.short_name,
    names: emojiItem.short_names,
    emoji: getEmoji(emojiItem.unified),
    category: emojiItem.category
  };

  if (emojiItem.skin_variations) {
    newData.variants = {};
    Object.keys(emojiItem.skin_variations).forEach(variation => {
      newData.variants[variation] = {
        name: emojiItem.short_name,
        key: `${emojiItem.short_name}-${variation}`,
        emoji: getEmoji(emojiItem.skin_variations[variation].unified)
      };
github TimeToKnow / emoji-panel / src / emoji-data.js View on Github external
const emojiData = require('emoji-datasource');
const categoryDataMap = require('./map').categoryDataMap;

const sortedEmojiData = emojiData
  .map((emoji, index) => Object.assign(emoji, { index }))
  .sort((emojiA, emojiB) => emojiA['sort_order'] - emojiB['sort_order'])
  .reduce((obj, emoji) => {
    const category = categoryDataMap[emoji.category];
    const categoryArray = obj[category] || [];
    return Object.assign(obj, {
      [category]:  categoryArray.concat(emoji)
    });
  }, {});

module.exports = sortedEmojiData;
github joeattardi / emoji-button / scripts / processEmojiData.js View on Github external
const categoryKeys = {
  'Smileys & People': 'smileys',
  'Animals & Nature': 'animals',
  'Food & Drink': 'food',
  Activities: 'activities',
  'Travel & Places': 'travel',
  Objects: 'objects',
  Symbols: 'symbols',
  Flags: 'flags',
  'Skin Tones': 'skinTones'
};

const categories = [];

rawData.sort((e1, e2) => e1.sort_order - e2.sort_order);
const newEmojiData = rawData.map(emojiItem => {
  let categoryIndex = categories.indexOf(emojiItem.category);
  if (categoryIndex < 0) {
    categories.push(emojiItem.category);
    categoryIndex = categories.length - 1;
  }

  const newData = {
    n: emojiItem.short_names,
    e: getEmoji(emojiItem.unified),
    c: categoryIndex
  };

  if (emojiItem.skin_variations) {
    newData.v = {};
    Object.keys(emojiItem.skin_variations).forEach(variation => {
      newData.v[variation] = {

emoji-datasource

Emoji data and images

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis