Convert Text Emoticons to Emoji – smile2emoji

Category: Javascript , Text | March 2, 2024
Author:emish89
Views Total:6 views
Official Page:Go to website
Last Update:March 2, 2024
License:MIT

Preview:

Convert Text Emoticons to Emoji – smile2emoji

Description:

In the world of digital communication, emojis have become a universal language, adding color and emotion to our texts.

smile2emoji is a simple-to-use JavaScript library that converts text emoticons like :), ^^, :blush: and even Unicode strings into their corresponding emoji images (😊).

It can scan text for emoticon patterns and replace them with emoji. This can help make conversations and content more visual and expressive.

How to use it:

1. Install the smile2emoji with NPM.

# NPM
$ npm i smile2emoji

2. The library exports four easy-to-use functions for converting text, detecting emoji patterns, and more. The main checkText() function scans a string for any defined emoticon patterns like :) or ^^ and replaces them with the corresponding emoji.

import { checkText } from 'smile2emoji'
// OR from a CDN
import { checkText } from "https://cdn.skypack.dev/smile2emoji";
const emoji = checkText(':)');

3. The fromUnicodeToEmoji() is a specialized function that directly translates Unicode to emojis

import { fromUnicodeToEmoji } from 'smile2emoji'
// OR from a CDN
import { fromUnicodeToEmoji } from "https://cdn.skypack.dev/smile2emoji";
// ☁️
const emoji = fromUnicodeToEmoji('2601');

4. The checkTextWithAutoSuggestions() and checkTextWithAutoSuggestionsAndUnicode() functions detect emoji syntax and replace it with the appropriate emoji even if it’s not an exact match.

import { checkTextWithAutoSuggestions } from 'smile2emoji'
import { checkTextWithAutoSuggestionsAndUnicode } from 'smile2emoji'
// OR from a CDN
import { checkTextWithAutoSuggestions } from "https://cdn.skypack.dev/smile2emoji";
import { checkTextWithAutoSuggestionsAndUnicode } from "https://cdn.skypack.dev/smile2emoji";
// 🎾
emoji = checkTextWithAutoSuggestions(':tenn');
// 🎾
emoji = checkTextWithAutoSuggestionsAndUnicode(':tenn');

Changelog:

v3.11.0 (03/02/2024)

  • update

v3.10.0 (02/04/2024)

  • release: package updated + produce esm output

v3.9.1 (01/31/2024)

  • Bugfix

v3.9.0 (12/28/2023)

  • commonjs: now the project is common js – chai 5 works
  • release-config: changed from .js to .cjs

You Might Be Interested In:


Leave a Reply