How to use the emojibase.fromHexcodeToCodepoint function in emojibase

To help you get started, we’ve selected a few emojibase 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 milesj / emojibase / packages / generator / src / parsers / parseData.ts View on Github external
const mapHexcode = (hexcode: string) => {
      if (map[hexcode]) {
        // An emoji may belong to multiple properties,
        // so keep a unique list of all applicable.
        map[hexcode].property = Array.from(new Set([...map[hexcode].property, ...emoji.property]));
      } else {
        map[hexcode] = {
          ...emoji,
          hexcode,
        };
      }
    };

    // A sequence of emoji
    if (rawHexcode.includes('..')) {
      const [lowCodepoint, highCodepoint] = fromHexcodeToCodepoint(rawHexcode, '..');

      for (let codepoint = lowCodepoint; codepoint <= highCodepoint; codepoint += 1) {
        mapHexcode(
          codepoint
            .toString(16)
            .padStart(4, '0')
            .toUpperCase(),
        );
      }

      // A single emoji
    } else {
      // v1.0 had a different structure
      if (version === '1.0') {
        emoji.type = property === 'emoji' ? EMOJI : TEXT;
        emoji.property = [