# @nxmix/emoji-seq-match

> Match Emoji combinations according to unicode emoji specification

Latest version **1.0.0** (published 2018-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nxmix/emoji-seq-match
pnpm add @nxmix/emoji-seq-match
yarn add @nxmix/emoji-seq-match
bun add @nxmix/emoji-seq-match
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-06-08 |
| First published | 2018-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 285.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | jacobbubu |
| Maintainers | jacobbubu, nxdeploy, zhengle |
| Keywords | emoji, width, combination, zwj, modifier, unicode, character, string, codepoint, code, point, is, detect, check |

## Links

- npm: https://www.npmjs.com/package/@nxmix/emoji-seq-match
- Repository: https://github.com/NXMIX/emoji-seq-match
- Homepage: https://github.com/NXMIX/emoji-seq-match#readme
- Issues: https://github.com/NXMIX/emoji-seq-match/issues
- npm.io page: https://npm.io/package/@nxmix/emoji-seq-match

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-06-08
- 0.1.0 — 2018-06-03

## README

# @nxmix/emoji-seq-match
[![Build Status](https://travis-ci.org/NXMIX/emoji-seq-match.svg?branch=master)](https://travis-ci.org/NXMIX/emoji-seq-match)
[![Coverage Status](https://coveralls.io/repos/github/NXMIX/emoji-seq-match/badge.svg)](https://coveralls.io/github/NXMIX/emoji-seq-match)
[![npm](https://img.shields.io/npm/v/@nxmix/emoji-seq-match.svg?maxAge=1000)](https://www.npmjs.com/package/@nxmix/emoji-seq-match/)

> 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](http://unicode.org/emoji/charts/emoji-sequences.html) 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](https://en.wikipedia.org/wiki/Terminal_(macOS)).

## Usage

### Install

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

[Typescript](https://www.typescriptlang.org) definition file is already included.

### EXAMPLES

```js
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:

```ts
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.

---
_Source: https://npm.io/package/@nxmix/emoji-seq-match · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
