emoji-detector-node
v1.0.5
Published
A simple emoji detection and extraction library for modern JavaScript environments (Node.js, Deno, Browser)
Maintainers
Readme
📦 emoji-detector-node
A simple emoji detection and extraction library for Node.js with no dependencies.
Supports CommonJS (require), ES Modules (import), and TypeScript out of the box.
Installation
npm install emoji-detector-nodeUsage
CommonJS (require)
Example 1
const { detect } = require("emoji-detector-node");
console.log(detect("Hello 😊🚀"));Output:
{
"originalText": "Hello 😊🚀",
"textOnly": "Hello",
"emojis": "😊🚀",
"isEmoji": true
}Example 2
const { detect } = require("emoji-detector-node");
console.log(detect("No emoji here"));Output:
{
"originalText": "No emoji here",
"textOnly": "No emoji here",
"emojis": "",
"isEmoji": false
}ES Modules (import)
Example 1
import { detect } from "emoji-detector-node";
console.log(detect("Flags 🇮🇳 mixed with text"));Output:
{
"originalText": "Flags 🇮🇳 mixed with text",
"textOnly": "Flags mixed with text",
"emojis": "🇮🇳",
"isEmoji": true
}Example 2
import { detect } from "emoji-detector-node";
console.log(detect("Only emojis 😍🔥💯"));Output:
{
"originalText": "Only emojis 😍🔥💯",
"textOnly": "",
"emojis": "😍🔥💯",
"isEmoji": true
}TypeScript Support
Example 1
Type definitions are included automatically.
import { detect } from "emoji-detector-node";
const result = detect("Hello World 😎");
console.log(result.originalText); // "Hello World 😎"
console.log(result.textOnly); // "Hello World"
console.log(result.emojis); // "😎"
console.log(result.isEmoji); // trueReturned Object
The `detect()` function always returns an object:
| Field | Type | Description |
|--------------|---------|----------------------------------------------|
| originalText | string | The (original input text) |
| textOnly | string | Text (without emojis) |
| emojis | string | Extracted (extracted emojies) |
| isEmoji | boolean | true (if at least one emoji was found, otherwise false) |Example Use Cases
- Filter emojis out of user input
- Detect if a message contains only text or emojis
- Extract emojis for analytics (e.g., most used emojis)
License
MIT © 2025 [Tukaram Todkari]