# nlcst-emoji-modifier

> nlcst utility to support emoji

Latest version **6.0.2** (published 2023-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install nlcst-emoji-modifier
pnpm add nlcst-emoji-modifier
yarn add nlcst-emoji-modifier
bun add nlcst-emoji-modifier
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.2 |
| Published | 2023-07-18 |
| First published | 2014-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 8 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Titus Wormer |
| Maintainers | wooorm, kmck |
| Keywords | unist, nlcst, nlcst-util, util, utility, emoticon, emoji |

## Links

- npm: https://www.npmjs.com/package/nlcst-emoji-modifier
- Repository: https://github.com/syntax-tree/nlcst-emoji-modifier
- Homepage: https://github.com/syntax-tree/nlcst-emoji-modifier#readme
- Issues: https://github.com/syntax-tree/nlcst-emoji-modifier/issues
- Funding: https://opencollective.com/unified
- npm.io page: https://npm.io/package/nlcst-emoji-modifier

## Dependencies (8)

- [gemoji](https://npm.io/package/gemoji.md) ^8.0.0
- [emoji-regex](https://npm.io/package/emoji-regex.md) ^10.0.0
- [@types/nlcst](https://npm.io/package/@types/nlcst.md) ^2.0.0
- [nlcst-to-string](https://npm.io/package/nlcst-to-string.md) ^4.0.0
- [unist-util-position](https://npm.io/package/unist-util-position.md) ^5.0.0
- [unist-util-generated](https://npm.io/package/unist-util-generated.md) ^3.0.0
- [nlcst-emoticon-modifier](https://npm.io/package/nlcst-emoticon-modifier.md) ^3.0.0
- [unist-util-visit-parents](https://npm.io/package/unist-util-visit-parents.md) ^6.0.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 6.0.2 (latest) — 2023-07-18
- 6.0.1 — 2023-07-18
- 6.0.0 — 2023-07-18
- 5.2.0 — 2023-01-19
- 5.1.0 — 2021-08-27
- 5.0.0 — 2021-04-20
- 4.1.1 — 2020-10-06
- 4.1.0 — 2020-06-13
- 4.0.0 — 2020-02-18
- 3.0.0 — 2019-06-12
- 2.0.3 — 2019-05-23
- 2.0.2 — 2018-05-02
- 2.0.1 — 2017-10-17
- 2.0.0 — 2017-10-16
- 1.1.0 — 2016-11-15
- … 6 more at https://npm.io/package/nlcst-emoji-modifier/versions

## README

# nlcst-emoji-modifier

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[nlcst][] utility to classify emoji and gemoji shortcodes as `EmoticonNode`s.

## Contents

*   [What is this?](#what-is-this)
*   [When should I use this?](#when-should-i-use-this)
*   [Install](#install)
*   [Use](#use)
*   [API](#api)
    *   [`emojiModifier(node)`](#emojimodifiernode)
*   [Types](#types)
*   [Compatibility](#compatibility)
*   [Related](#related)
*   [Contribute](#contribute)
*   [License](#license)

## What is this?

This utility searches for emoji (`👍`) and gemoji shortcodes (`:+1:`) and turns
them into separate nodes.

## When should I use this?

This package is a tiny utility that helps when dealing with emoji and gemoji in
natural language.
The plugin [`retext-emoji`][retext-emoji] wraps this utility and others at a
higher-level (easier) abstraction.

## Install

This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:

```sh
npm install nlcst-emoji-modifier
```

In Deno with [`esm.sh`][esmsh]:

```js
import {emojiModifier} from 'https://esm.sh/nlcst-emoji-modifier@6'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
  import {emojiModifier} from 'https://esm.sh/nlcst-emoji-modifier@6?bundle'
</script>
```

## Use

```js
import {emojiModifier} from 'nlcst-emoji-modifier'
import {ParseEnglish} from 'parse-english'
import {inspect} from 'unist-util-inspect'

const english = new ParseEnglish()
english.tokenizeSentencePlugins.unshift(emojiModifier)

console.log(inspect(english.parse('It’s raining :cat:s and :dog:s.')))
```

Yields:

```txt
RootNode[1] (1:1-1:32, 0-31)
└─ ParagraphNode[1] (1:1-1:32, 0-31)
   └─ SentenceNode[11] (1:1-1:32, 0-31)
      ├─ WordNode[3] (1:1-1:5, 0-4)
      │  ├─ TextNode: "It" (1:1-1:3, 0-2)
      │  ├─ PunctuationNode: "’" (1:3-1:4, 2-3)
      │  └─ TextNode: "s" (1:4-1:5, 3-4)
      ├─ WhiteSpaceNode: " " (1:5-1:6, 4-5)
      ├─ WordNode[1] (1:6-1:13, 5-12)
      │  └─ TextNode: "raining" (1:6-1:13, 5-12)
      ├─ WhiteSpaceNode: " " (1:13-1:14, 12-13)
      ├─ EmoticonNode: ":cat:" (1:14-1:19, 13-18)
      ├─ WordNode[1] (1:19-1:20, 18-19)
      │  └─ TextNode: "s" (1:19-1:20, 18-19)
      ├─ WhiteSpaceNode: " " (1:20-1:21, 19-20)
      ├─ WordNode[1] (1:21-1:24, 20-23)
      │  └─ TextNode: "and" (1:21-1:24, 20-23)
      ├─ WhiteSpaceNode: " " (1:24-1:25, 23-24)
      ├─ EmoticonNode: ":dog:" (1:25-1:30, 24-29)
      └─ WordNode[2] (1:30-1:32, 29-31)
         ├─ TextNode: "s" (1:30-1:31, 29-30)
         └─ PunctuationNode: "." (1:31-1:32, 30-31)
```

## API

This package exports the identifier [`emojiModifier`][api-emoji-modifier].
There is no default export.

### `emojiModifier(node)`

Classify emoji (👍) and Gemoji (GitHub emoji, :+1:) in `node` as `Emoticon`s.

See [`Emoticon` in `nlcst-emoticon-modifier`][emoticon-mofifier-emoticon].

###### Parameters

*   `node` ([`Sentence`][sentence])
    — sentence to transform

###### Returns

Nothing (`undefined`).

## Types

This package is fully typed with [TypeScript][].
It exports no additional types

See [`Emoticon` in `nlcst-emoticon-modifier`][emoticon-mofifier-emoticon] on
how to register it in TypeScript.

## Compatibility

Projects maintained by the unified collective are compatible with maintained
versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, `nlcst-emoji-modifier@^6`,
compatible with Node.js 16.

## Related

*   [`nlcst-affix-emoticon-modifier`](https://github.com/syntax-tree/nlcst-affix-emoticon-modifier)
    — merge affix emoticons into the previous sentence in nlcst
*   [`nlcst-emoticon-modifier`](https://github.com/syntax-tree/nlcst-emoticon-modifier)
    — support emoticons

## Contribute

See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## License

[MIT][license] © [Titus Wormer][author]

<!-- Definitions -->

[build-badge]: https://github.com/syntax-tree/nlcst-emoji-modifier/workflows/main/badge.svg

[build]: https://github.com/syntax-tree/nlcst-emoji-modifier/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/nlcst-emoji-modifier.svg

[coverage]: https://codecov.io/github/syntax-tree/nlcst-emoji-modifier

[downloads-badge]: https://img.shields.io/npm/dm/nlcst-emoji-modifier.svg

[downloads]: https://www.npmjs.com/package/nlcst-emoji-modifier

[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=nlcst-emoji-modifier

[size]: https://bundlejs.com/?q=nlcst-emoji-modifier

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[collective]: https://opencollective.com/unified

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[chat]: https://github.com/syntax-tree/unist/discussions

[npm]: https://docs.npmjs.com/cli/install

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[typescript]: https://www.typescriptlang.org

[license]: license

[author]: https://wooorm.com

[health]: https://github.com/syntax-tree/.github

[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md

[support]: https://github.com/syntax-tree/.github/blob/main/support.md

[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md

[retext-emoji]: https://github.com/retextjs/retext-emoji

[nlcst]: https://github.com/syntax-tree/nlcst

[sentence]: https://github.com/syntax-tree/nlcst#sentence

[emoticon-mofifier-emoticon]: https://github.com/syntax-tree/nlcst-emoticon-modifier#emoticon

[api-emoji-modifier]: #emojimodifiernode

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