{"id":11399,"library":"nlcst-affix-emoticon-modifier","title":"NLCST Affix Emoticon Modifier","description":"nlcst-affix-emoticon-modifier is a utility within the unified ecosystem designed to process Natural Language Concrete Syntax Tree (NLCST) nodes. Its primary function is to identify and re-position emoticons that appear at the beginning of a sentence, moving them to the end of the preceding sentence. This addresses common linguistic patterns where users place emoticons as a reaction to the previous thought, even after terminal punctuation. The current stable version is 3.0.0, which requires Node.js 16+. While a low-level utility, it forms a crucial part of more abstracted tools like `retext-emoji`. The project follows semver for releases, with significant breaking changes in major versions, particularly the move to ESM-only in v2 and further API adjustments in v3.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/nlcst-affix-emoticon-modifier","tags":["javascript","unist","nlcst","nlcst-util","util","utility","affix","emoticon","typescript"],"install":[{"cmd":"npm install nlcst-affix-emoticon-modifier","lang":"bash","label":"npm"},{"cmd":"yarn add nlcst-affix-emoticon-modifier","lang":"bash","label":"yarn"},{"cmd":"pnpm add nlcst-affix-emoticon-modifier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to create the `EmoticonNode`s that this utility processes. Also provides the `Emoticon` type since v3.0.0.","package":"nlcst-emoticon-modifier","optional":false},{"reason":"Can also produce `EmoticonNode`s that this utility processes, often used alongside `nlcst-emoticon-modifier`.","package":"nlcst-emoji-modifier","optional":true},{"reason":"Commonly used parser in examples and workflows for building an NLCST tree to apply modifiers.","package":"parse-english","optional":true}],"imports":[{"note":"This package is ESM-only since v2.0.0, and requires Node.js 16+ since v3.0.0. CommonJS `require` will result in an error.","wrong":"const affixEmoticonModifier = require('nlcst-affix-emoticon-modifier')","symbol":"affixEmoticonModifier","correct":"import { affixEmoticonModifier } from 'nlcst-affix-emoticon-modifier'"},{"note":"The `Emoticon` type was removed from `nlcst-affix-emoticon-modifier` in v3.0.0. It must now be imported directly from `nlcst-emoticon-modifier`.","wrong":"import type { Emoticon } from 'nlcst-affix-emoticon-modifier'","symbol":"Emoticon (type)","correct":"import type { Emoticon } from 'nlcst-emoticon-modifier'"}],"quickstart":{"code":"import {affixEmoticonModifier} from 'nlcst-affix-emoticon-modifier'\nimport {emoticonModifier} from 'nlcst-emoticon-modifier'\nimport {ParseEnglish} from 'parse-english'\nimport {inspect} from 'unist-util-inspect'\n\nconst parser = new ParseEnglish()\n// Register emoticonModifier to tokenize emoticons into EmoticonNodes\nparser.tokenizeSentencePlugins.unshift(emoticonModifier)\n// Register affixEmoticonModifier to move these nodes after terminal punctuation\nparser.tokenizeParagraphPlugins.unshift(affixEmoticonModifier)\n\nconst text = 'Hey. :) How is it going?'\nconst tree = parser.parse(text)\n\nconsole.log(inspect(tree))\n/* Expected output will show ' :)' moved into the first sentence. */","lang":"typescript","description":"This example demonstrates how to parse a sentence with an initial emoticon and then use `affixEmoticonModifier` to move it into the previous sentence in the NLCST tree."},"warnings":[{"fix":"Migrate your project to use ES modules (`import`/`export` syntax). Ensure your `package.json` specifies `\"type\": \"module\"` or use `.mjs` file extensions for ES module files.","message":"The package is now ESM-only (ECMAScript Modules). CommonJS `require()` is no longer supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade your Node.js runtime environment to version 16 or a newer LTS release.","message":"This package now requires Node.js version 16 or higher to run.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Avoid relying on internal or undocumented paths. Always import public APIs directly from the main package entry point, e.g., `import { affixEmoticonModifier } from 'nlcst-affix-emoticon-modifier'`.","message":"The package now uses the `exports` field in its `package.json`, which affects module resolution and restricts direct deep imports or access to previously public internal paths.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"If you were importing the `Emoticon` type, you must now import it from `nlcst-emoticon-modifier` instead: `import type { Emoticon } from 'nlcst-emoticon-modifier'`.","message":"The `Emoticon` TypeScript type has been removed from `nlcst-affix-emoticon-modifier`.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your import statement to use ES module syntax: `import { affixEmoticonModifier } from 'nlcst-affix-emoticon-modifier'`. Ensure your project's `package.json` has `\"type\": \"module\"` or you are using `.mjs` file extensions.","cause":"Attempting to use `require()` to import `nlcst-affix-emoticon-modifier`, which is an ESM-only package.","error":"ERR_REQUIRE_ESM (or similar 'require is not defined in ES module scope')"},{"fix":"Ensure your Node.js version is 16 or newer. Verify that your project is correctly configured for ES modules, using `import` statements and appropriate `package.json` settings.","cause":"This error often occurs when running on an unsupported Node.js version (older than 16) or due to incorrect interoperability between CommonJS and ES Modules.","error":"TypeError: affixEmoticonModifier is not a function"},{"fix":"The `Emoticon` type has been moved. Import it from `nlcst-emoticon-modifier` instead: `import type { Emoticon } from 'nlcst-emoticon-modifier'`.","cause":"Attempting to import the `Emoticon` type directly from `nlcst-affix-emoticon-modifier` in TypeScript after upgrading to v3.0.0.","error":"Property 'Emoticon' does not exist on type 'typeof import(\"nlcst-affix-emoticon-modifier\")'"}],"ecosystem":"npm"}