How to use the emoji-datasource.forEach 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 tunoltd / emoji-mart-native / scripts / local-images / build.js View on Github external
module.exports = (options) => {
  delete require.cache[require.resolve('emoji-datasource')]
  var emojiData = require('emoji-datasource')

  var data = { compressed: true, emojis: {} }

  emojiData.sort((a, b) => {
    var aTest = a.sort_order || a.short_name,
      bTest = b.sort_order || b.short_name

    return aTest - bTest
  })

  emojiData.forEach((datum) => {
    var keywords = []

    var localImageSets = options.sets || sets

    // Local images
    datum.localImages = {}
    localImageSets.forEach((set) => {
      var key = `has_img_${set}`
      if (datum[key]) {
        datum.localImages[set] = [`require('./img-${set}-64/${datum.image}')`]

        // Skin variations
        if (datum.skin_variations) {
          for (let skinKey in datum.skin_variations) {
            var skinVariations = datum.skin_variations[skinKey]
            if (skinVariations[key])
github keybase / client / shared / markdown / generate-emoji-parser.js View on Github external
function genEmojiData() {
  const emojiIndexByChar = {}
  const emojiLiterals = []
  const emojiCharacters = new Set()
  function addEmojiLiteral(unified, name, skinTone) {
    const chars = unified.split('-').map(c => String.fromCodePoint(parseInt(c, 16)))
    const literals = chars.map(c => UTF162JSON(c)).join('')

    emojiIndexByChar[chars.join('')] = `:${name}:` + (skinTone ? `:skin-tone-${skinTone}:` : '')
    emojiLiterals.push(literals)
    chars.forEach(c => emojiCharacters.add(c))
  }

  emojiData.forEach(emoji => {
    if (emoji.skin_variations) {
      Object.keys(emoji.skin_variations).forEach((k, idx) =>
        addEmojiLiteral(emoji.skin_variations[k].unified, emoji.short_name, idx + 1)
      )
    }
    emoji.variations.forEach(v => addEmojiLiteral(v, emoji.short_name))
    addEmojiLiteral(emoji.unified, emoji.short_name)
  })

  emojiLiterals.sort((a, b) => b.length - a.length)

  return {emojiIndexByChar, emojiLiterals, emojiCharacters}
}
github TypeCtrl / ngx-emoji-mart / scripts / build-data.ts View on Github external
}
    delete datum[`has_img_${x}`];
  });
  if (!hidden.length) {
    return;
  }
  datum.hidden = hidden;
}

function setupSheet(datum: any) {
  datum.sheet = [datum.sheet_x, datum.sheet_y];
  delete datum.sheet_x;
  delete datum.sheet_y;
}

emojiData.forEach((datum: any) => {
  const category = datum.category;
  const keywords = [];
  let categoryIndex;

  if (!datum.category) {
    throw new Error(`"${datum.short_name}" doesn’t have a category`);
  }

  if (!datum.name) {
    datum.name = datum.short_name.replace(/\-/g, ' ');
  }
  datum.name = inflection.titleize(datum.name || '');

  if (!datum.name) {
    throw new Error(`"${datum.short_name}" doesn’t have a name`);
  }
github tunoltd / emoji-mart-native / scripts / build.js View on Github external
categoriesIndex = {}

  categories.forEach((category, i) => {
    let [name, id] = category
    data.categories[i] = {id: id, name: name, emojis: []}
    categoriesIndex[name] = i
  })

  emojiData.sort((a, b) => {
    var aTest = a.sort_order || a.short_name,
      bTest = b.sort_order || b.short_name

    return aTest - bTest
  })

  emojiData.forEach((datum) => {
    var category = datum.category,
      keywords = [],
      categoryIndex

    if (!datum.category) {
      throw new Error('“' + datum.short_name + '” doesn’t have a category')
    }

    if (options.sets) {
      var keepEmoji = false

      options.sets.forEach((set) => {
        if (keepEmoji) return

        if (datum[`has_img_${set}`]) {
          keepEmoji = true
github svelto / svelto / src / lib / emoji / data / raw / make.js View on Github external
};

  indexes[category] = i;

});

emojiData.sort ( ( a, b ) => {

  const aTest = a.sort_order || a.short_name,
        bTest = b.sort_order || b.short_name;

  return aTest - bTest;

});

emojiData.forEach ( datum => {

  datum.name || (datum.name = datum.short_name.replace ( /\-/g, ' ' ) );
  datum.name = inflection.titleize ( datum.name || '' );

  if ( datum.category === 'Flags' ) {
    const code = datum.short_name.split ( '-' )[1].toUpperCase ();
    datum.name = `Flag of ${countries[code].name}`;
  }

  if ( datum.texts && datum.texts.length ) {
    datum.emoticons = datum.texts;
  } else if ( datum.text ) {
    datum.emoticons = [datum.text];
  }

  if ( emojiLib.lib[datum.short_name] ) {

emoji-datasource

Emoji data and images

MIT
Latest version published 10 months ago

Package Health Score

66 / 100
Full package analysis