The `nlcst-emoji-modifier` package is an NLCST utility designed to classify both standard Unicode emoji (e.g., π) and GitHub-style gemoji shortcodes (e.g., `:cat:`) within natural language text by transforming them into `EmoticonNode`s in the syntax tree. The current stable version is 6.0.2. This project, part of the `unified` collective, releases new major versions aligned with Node.js LTS support, dependency updates, and shifts to modern JavaScript module practices, ensuring ongoing compatibility and performance. It functions as a foundational component for advanced linguistic analysis, often used implicitly by higher-level plugins like `retext-emoji`. Its key differentiator lies in its specific integration within the NLCST ecosystem for detailed emoji and emoticon processing.
npm install nlcst-emoji-modifierVerified import paths β ran on the pinned version, not inferred.
This example demonstrates how to integrate `nlcst-emoji-modifier` into a `ParseEnglish` pipeline to tokenize emoji and gemoji shortcodes as `EmoticonNode`s.
Upgrade your Node.js environment to version 16 or newer. For projects requiring older Node.js, pin `nlcst-emoji-modifier` to `<6.0.0`.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or `.mjs` files) and use `import { emojiModifier } from 'nlcst-emoji-modifier'` instead of `require()`.Update your type imports to `import type { Emoticon } from 'nlcst-emoticon-modifier'`. You may need to install `nlcst-emoticon-modifier` if you haven't already.Modify your code to expect `undefined` from `emojiModifier` and adjust subsequent logic accordingly. The modifier operates by side-effect on the passed `node`.
Review your TypeScript configurations and usages of `unist-util-visit` within your dependency tree, ensuring compatibility with its v2.0.0 API.
Evaluate if `retext-emoji` better suits your needs for general emoji processing in `retext` pipelines, as it wraps `nlcst-emoji-modifier`.
Convert your file to an ES module (e.g., by adding `"type": "module"` to `package.json` or renaming to `.mjs`) and use `import { emojiModifier } from 'nlcst-emoji-modifier'`.Ensure your Node.js environment or build setup treats your files as ES modules. This might involve setting `"type": "module"` in your `package.json` or explicitly using `.mjs` file extensions.
You must use `import()` or convert your consuming module to ESM. For example, `import { emojiModifier } from 'nlcst-emoji-modifier'`.The `Emoticon` type was moved. Import it from `nlcst-emoticon-modifier` instead: `import type { Emoticon } from 'nlcst-emoticon-modifier'`.Upgrade your Node.js runtime to version 16 or newer. Verify your `package.json` `engines` field if distributing your package.