How to use emojibase-data - 8 common examples

To help you get started, we’ve selected a few emojibase-data 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 hfg-gmuend / openmoji / helpers / generate-data-tables.js View on Github external
const fs = require('fs');
const _ = require('lodash');
const csvWriter = require('csv-write-stream');
const csvParse = require('csv-parse/lib/sync');

const emojibaseData = require('emojibase-data/en/data.json');
const emojibaseGroups = require('emojibase-data/meta/groups.json');
const groups = emojibaseGroups.groups;
const subgroups = emojibaseGroups.subgroups;


// -- helper functions --
const loadCsv = (filePath) => {
  const content = fs.readFileSync(filePath, 'utf8');
  return csvParse(content, {columns: true});
}
const arrayToEmojiDict = (array) => {
  return array.reduce((o, a) => Object.assign(o, { [a.emoji]: a }), {});
}
const writeCsv = (data, filePath) => {
  const csvOut = csvWriter();
  csvOut.pipe(fs.createWriteStream(filePath));
  for (d of data) csvOut.write(d);
  csvOut.end();
github kevinfaguiar / cool-emoji-picker / utils / remove-unused.js View on Github external
let compact = require('emojibase-data/en/compact.json');
let groupMetaData = require('emojibase-data/meta/groups.json');
const fs = require('fs');

const emojiArray = [];

for (let i = 0; i < compact.length; i++) {
  let emojiGroupFound = emojiArray.find(emojiGroup => emojiGroup.group === compact[i].group);
  let emojiGroup = {};

  if (emojiGroupFound !== undefined) {
    emojiGroup = emojiGroupFound;
  } else {
    emojiGroup = { group: compact[i].group, emojiList: [] };
  }

  let emojiObj = { unicode: compact[i].unicode, /* tags: compact[i].tags */ };
  if (compact[i].skins !== undefined) {
    emojiObj.skins = [];
    for (let j = 0; j < compact[i].skins.length; j++) {
      emojiObj.skins.push({ 
        unicode: compact[i].skins[j].unicode, 
        /* tags: compact[i].skins[j].tags */
github hfg-gmuend / openmoji / helpers / generate-data-tables.js View on Github external
const fs = require('fs');
const _ = require('lodash');
const csvWriter = require('csv-write-stream');
const csvParse = require('csv-parse/lib/sync');

const emojibaseData = require('emojibase-data/en/data.json');
const emojibaseGroups = require('emojibase-data/meta/groups.json');
const groups = emojibaseGroups.groups;
const subgroups = emojibaseGroups.subgroups;


// -- helper functions --
const loadCsv = (filePath) => {
  const content = fs.readFileSync(filePath, 'utf8');
  return csvParse(content, {columns: true});
}
const arrayToEmojiDict = (array) => {
  return array.reduce((o, a) => Object.assign(o, { [a.emoji]: a }), {});
}
const writeCsv = (data, filePath) => {
  const csvOut = csvWriter();
  csvOut.pipe(fs.createWriteStream(filePath));
  for (d of data) csvOut.write(d);
  csvOut.end();
}
github kevinfaguiar / cool-emoji-picker / utils / remove-unused.js View on Github external
})
    }
  }
  
  if (emojiGroupFound !== undefined) {
    emojiGroup.emojiList.push(emojiObj);
  } else {
    emojiGroup.emojiList.push(emojiObj);
    emojiArray.push(emojiGroup);
  }
}
const emojiArrayString = JSON.stringify(emojiArray);
console.log('emoji-data/emoji-all-groups.json');
fs.writeFileSync(`../emoji-data/emoji-all-groups.json`, emojiArrayString, 'utf-8'); 

const groupMeta = groupMetaData.groups;
for (let i = 0; i < emojiArray.length; i++) {
  let emojiGroupName = '';
  for (let group in groupMeta) {
    if(group == emojiArray[i].group) {
      emojiGroupName = groupMeta[group];
      break;
    } 
  }
  
  const emojiGroupString = JSON.stringify(emojiArray[i]);
  console.log(`emoji-data/emoji-group-${emojiGroupName}.json`);
  fs.writeFileSync(`../emoji-data/emoji-group-${emojiGroupName}.json`, emojiGroupString, 'utf-8'); 
}
github kevinfaguiar / cool-emoji-picker / utils / remove-unused-with-tags.js View on Github external
emojiObj.skins.push({ 
          unicode: emojiPackLang[i].skins[j].unicode, 
          tags: emojiPackLang[i].skins[j].tags
        })
      }
    }
    
    if (emojiGroupFound !== undefined) {
      emojiGroup.emojiList.push(emojiObj);
    } else {
      emojiGroup.emojiList.push(emojiObj);
      emojiArray.push(emojiGroup);
    }
  }

  const groupMeta = groupMetaData.groups;
  for (let i = 0; i < emojiArray.length; i++) {
    if (i === 2) { continue; } 
    else {
      let emojiGroupName = '';
      for (let group in groupMeta) {
        if(group == emojiArray[i].group) {
          emojiGroupName = groupMeta[group];
          break;
        } 
      }
      
      const emojiGroupString = JSON.stringify(emojiArray[i]);
      console.log(`emoji-data/${lang}/emoji-group-${emojiGroupName}.json`);
      fs.writeFileSync(`./src/emoji-data/${lang}/emoji-group-${emojiGroupName}.json`, emojiGroupString, 'utf-8');
    }
  }
github idleberg / vscode-emoji-code / src / build.js View on Github external
const writeSnippets = (type, prefix = '', suffix = '') => {

    for (let i = 0; i < emojiAll.length; i++) {
        let emoji, json, name, output, unicode;

        if (typeof emojiAll[i].name != 'undefined' && emojiAll[i].name !== null ) {
            name = emojiAll[i].name.toLowerCase().replace(/[\s,\.]+/g, '-');
        } else {
            name = emojiAll[i].short_name;
        }

        unicodes = emojiAll[i].hexcode.split('-');

        unicodes.forEach(function(unicode, index) {
          if (type === 'python') {
            unicode = String('0000000' + unicode).slice(-8);
          } else if (type === 'csharp') {
            unicode = findSurrogatePair(parseInt(unicode, 16)).join('\\u');
          }
github vanilla / vanilla / plugins / rich-editor / src / scripts / Editor / EmojiPopover.jsx View on Github external
import { log } from "@core/utility";
import EmojiButton from "./EmojiButton";
import * as Icons from "./Icons";
import Popover from "./Generic/Popover";
import { withEditor, editorContextTypes } from "./ContextProvider";

const buttonSize = 39;
const colSize = 7;
const rowSize = 7;
const rowIndexesByGroupId = {};
const cellIndexesByGroupId = {};

/**
 * Get start positions for each category
 */
emojis.map((data, key) => {
    const groupID = data.group;
    if (!(groupID in rowIndexesByGroupId)) {
        rowIndexesByGroupId[groupID] = Math.floor(key / colSize);
        cellIndexesByGroupId[groupID] = key;
    }
});

log("rowIndexesByGroupId: ", rowIndexesByGroupId);

export class EmojiPopover extends React.PureComponent {
    static propTypes = {
        ...editorContextTypes,
        isVisible: PropTypes.bool.isRequired,
        closeMenu: PropTypes.func.isRequired,
        blurHandler: PropTypes.func.isRequired,
        popoverTitleID: PropTypes.string.isRequired,