How to use the node-emoji/lib/emojifile.data function in node-emoji

To help you get started, we’ve selected a few node-emoji 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 moqada / rn-twemoji / scripts / gen-names.js View on Github external
utils.getBaseImages(conf.BASE_SIZE).forEach(image => {
    const basename = path.basename(image, '.png');
    const emojiKey = basename.split('-').map(code => {
      if (code.length < UNICODE_LENGTH) {
        return `${'0'.repeat(UNICODE_LENGTH - code.length)}${code}`;
      }
      return code;
    }).join('-');
    const data = emojifile.data[emojiKey];
    if (!data) {
      console.log(`skipping ${basename}...`);
      return undefined;
    }
    data[3].forEach(name => {
      if (names[name]) {
        throw Error(`Duplicate emoji name: ${name}`);
      }
      const dist = `${conf.NAME_DIR}/${name}.js`;
      const output = `
module.exports = require('${conf.IMG_DIR}/${image}');
`;
      console.log(`Generating ${dist}...`);
      fs.writeFileSync(dist, output);
    });
    return undefined;