How to use the emoji-datasource.sort 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]) {
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 svelto / svelto / src / lib / emoji / data / raw / make.js View on Github external
indexes    = {};

categories.forEach ( ( category, i ) => {

  data.categories[i] = {
    name: category,
    title: titles[i],
    icon: icons[i],
    emojis: []
  };

  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}`;
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 => {
github tunoltd / emoji-mart-native / scripts / 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, categories: [], emojis: {}, aliases: {}},
    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) {
github TypeCtrl / ngx-emoji-mart / scripts / build-data.ts View on Github external
];
const sets = [
  'apple',
  'google',
  'twitter',
  'facebook',
  'messenger',
];

catPairs.forEach((category, i) => {
  const [name, id] = category;
  categories[i] = { id: id, name: name, emojis: [] };
  categoriesIndex[name] = i;
});

emojiData.sort((a: any, b: any) => {
  const aTest = a.sort_order || a.short_name,
    bTest = b.sort_order || b.short_name;

  return aTest - bTest;
});

function missingSets(datum: any) {
  const hidden: any[] = [];
  sets.forEach(x => {
    if (!datum[`has_img_${x}`]) {
      hidden.push(x);
    }
    delete datum[`has_img_${x}`];
  });
  if (!hidden.length) {
    return;

emoji-datasource

Emoji data and images

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis