New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nxmix/emoji-seq-match

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nxmix/emoji-seq-match

Match Emoji combinations according to unicode emoji specification

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by240%
Maintainers
3
Weekly downloads
 
Created
Source

@nxmix/emoji-seq-match

Build Status Coverage Status npm

Match Emoji combinations according to unicode emoji specification

Why

Different Emoji character combinations may visually produce different widths, for examples:

👶 + 🏼 => 👶🏼  // Base emoji with skin-tone modifier
👨 + 👩 + 👧 + 👦  => 👨‍👩‍👧‍👦  // Emoji characters joined with zero-witdh joiner (\u0200d)

Emoji Sequences, v11.0 defines these combinations.

The reason for creating this module is that I need to get the visual width of a string in terminal application to calculate the cursor's movement distance. To achieve this, I have to first create a method to find out if a string insludes a specification-defined Emoji combination.

Please noe that different terminal apps have different levels of implementation of the specification, including even the latest macOS Terminal.

Usage

Install

npm i @nxmix/emoji-seq-match --save

Typescript definition file is already included.

EXAMPLES

const getMatchedLength = require('@nxmix/emoji-seq-match').default;

getMatchedLength('👶🏼');
//=> 2

getMatchedLength('🐶🏼'); // puppy does not have skin tone combination" 
//=> 0

getMatchedLength("👶🏽👩‍👩‍👦‍👦", 2); // from a 'start' postion to match
//=> 7, 'start' is counted by character not visual width

getMatchedLength(['👶', '🏼']); // also accepts an array of strings
// => 2

Using ES2015w Modules:

import getMatchedLength from '@nxmix/emoji-seq-match';

getMatchedLength('👶🏼');
//=> 2

Tool

Running npm run parse-spec will download the specification files from http://unicode.org/Public/emoji/11.0/ and place the converted json files in the ./emoji-sequences directory.

Keywords

FAQs

Package last updated on 08 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc