Registry / serialization / nlcst-emoji-modifier

nlcst-emoji-modifier

JSON β†’
library6.0.2jsnpmunverified

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-modifier
INSTALL
IMPORT
SIG Β· NLCST-EMOJI-MODIFI
N
nlcst-emoji-modifier
serializationjavascriptv6.0.2
Install
β€”
Import
β€”
Disk
β€”
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? Β· npm install
Install Γ— environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim Β· musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths β€” ran on the pinned version, not inferred.

emojiModifier
βœ“ import { emojiModifier } from 'nlcst-emoji-modifier'
βœ— const emojiModifier = require('nlcst-emoji-modifier')
The package is ESM-only since v5.0.0, and Node.js 16+ is required since v6.0.0. CommonJS `require` will result in errors.
Emoticon
βœ“ import type { Emoticon } from 'nlcst-emoticon-modifier'
βœ— import type { Emoticon } from 'nlcst-emoji-modifier'
Since v6.0.0, the `Emoticon` type has been moved to the `nlcst-emoticon-modifier` package. Attempting to import it from `nlcst-emoji-modifier` will fail.
emojiModifier (Deno/Browser)
βœ“ import {emojiModifier} from 'https://esm.sh/nlcst-emoji-modifier@6'
For Deno and browser environments, use `esm.sh` with the major version specifier for direct module imports.

This example demonstrates how to integrate `nlcst-emoji-modifier` into a `ParseEnglish` pipeline to tokenize emoji and gemoji shortcodes as `EmoticonNode`s.

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.'))) // Expected output (simplified): // RootNode // └─ ParagraphNode // └─ SentenceNode // β”œβ”€ WordNode: "It’s" // β”œβ”€ WhiteSpaceNode: " " // β”œβ”€ WordNode: "raining" // β”œβ”€ WhiteSpaceNode: " " // β”œβ”€ EmoticonNode: ":cat:" // β”œβ”€ WordNode: "s" // β”œβ”€ WhiteSpaceNode: " " // β”œβ”€ WordNode: "and" // β”œβ”€ WhiteSpaceNode: " " // β”œβ”€ EmoticonNode: ":dog:" // └─ WordNode: "s."
Debug
Known issues
breakingVersion 6.0.0 requires Node.js 16 or higher. Older Node.js versions are no longer supported.
fix
Upgrade your Node.js environment to version 16 or newer. For projects requiring older Node.js, pin `nlcst-emoji-modifier` to `<6.0.0`.
affects: >=6.0.0
breakingThe package transitioned to ESM-only starting from v5.0.0, and explicitly uses the `exports` field since v6.0.0. This significantly changes how it's imported.
fix
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()`.
affects: >=5.0.0
breakingThe `Emoticon` TypeScript type was removed from `nlcst-emoji-modifier` in v6.0.0. It is now exported by `nlcst-emoticon-modifier`.
fix
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.
affects: >=6.0.0
breakingThe `emojiModifier` function now explicitly yields `undefined` (returns nothing). If you were relying on a return value, your code will need adjustment.
fix
Modify your code to expect `undefined` from `emojiModifier` and adjust subsequent logic accordingly. The modifier operates by side-effect on the passed `node`.
affects: >=6.0.0
breakingVersion 4.0.0 updated `unist-util-visit`, which could be a breaking change for TypeScript users who didn't explicitly expect TypeScript in their dependents.
fix
Review your TypeScript configurations and usages of `unist-util-visit` within your dependency tree, ensuring compatibility with its v2.0.0 API.
affects: >=4.0.0
gotchaThis utility is a low-level NLCST modifier. For a higher-level, easier-to-use abstraction that integrates this and other related utilities, consider `retext-emoji`.
fix
Evaluate if `retext-emoji` better suits your needs for general emoji processing in `retext` pipelines, as it wraps `nlcst-emoji-modifier`.
affects: always
Errors
Common errors & fixes
TypeError: emojiModifier is not a function
Attempting to use CommonJS `require()` syntax to import `nlcst-emoji-modifier` which is an ESM-only package.
fix
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'`.
SyntaxError: Cannot use import statement outside a module
Using ES module `import` syntax in a CommonJS context without proper configuration.
fix
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.
Error [ERR_REQUIRE_ESM]: require() of ES Module [path] not supported. Instead change the require of [path] to a dynamic import() or change 'type': 'module' in your package.json or use a .mjs extension.
Trying to `require()` this package (ESM-only) from a CommonJS module.
fix
You must use `import()` or convert your consuming module to ESM. For example, `import { emojiModifier } from 'nlcst-emoji-modifier'`.
Property 'Emoticon' does not exist on type 'typeof import("nlcst-emoji-modifier")'
TypeScript error when trying to import the `Emoticon` type from `nlcst-emoji-modifier` after version 6.0.0.
fix
The `Emoticon` type was moved. Import it from `nlcst-emoticon-modifier` instead: `import type { Emoticon } from 'nlcst-emoticon-modifier'`.
UnhandledPromiseRejectionWarning: Error: [Error message about Node.js version]
Running `nlcst-emoji-modifier` v6.0.0+ on an unsupported Node.js version (<16).
fix
Upgrade your Node.js runtime to version 16 or newer. Verify your `package.json` `engines` field if distributing your package.
Upgrade
Version history
6.0.2latest on npm
Audit
Dependencies
@types/nlcstrequiredProvides TypeScript type definitions for NLCST nodes.
nlcst-emoticon-modifieroptionalRequired for importing the `Emoticon` type definition for TypeScript users after v6.0.0, although not a direct runtime dependency for the `emojiModifier` function itself.
Agent activity
10 hits Β· last 30 days
node
8
OpenAI (training)
1
Resources
nlcst-emoji-modifier β€” npm install nlcst-emoji-modifier Β· libregistry