1.0.1 • Published 11 months ago

@kvpasupuleti/text-to-emoji-converter v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Text to Emoji Converter

A flexible and customizable text-to-emoji converter for JavaScript and TypeScript applications.

Installation

If you are using npm

npm install @kvpasupuleti/text-to-emoji-converter

If you are using yarn

yarn add @kvpasupuleti/text-to-emoji-converter

Usage

Basic Usage

import { EmojiConverter } from '@kvpasupuleti/text-to-emoji-converter';

// Create a new converter instance
const converter = new EmojiConverter();

// Convert text to emojis
const result = converter.convert('I love pizza!');
console.log(result); // "🙋‍♂️ ❤️ 🍕!"

Custom Emoji Mappings

// Add custom mappings during initialization
const customMappings = {
  'awesome': '🌟',
  'coding': '👨‍💻',
};
const converter = new EmojiConverter(customMappings);

// Or add them later
converter.addMappings({
  'fantastic': '✨',
  'javascript': '💛',
});

// Remove specific mappings
converter.removeMappings(['coding', 'javascript']);

// Reset to default mappings
converter.resetToDefault();

// Get current mappings
const currentMappings = converter.getMappings();

API Reference

EmojiConverter

Constructor

constructor(customEmojiMap?: EmojiMap)

Creates a new EmojiConverter instance with optional custom emoji mappings.

Methods

convert(text: string): string

Converts text to emojis using the configured emoji map.

addMappings(newMappings: EmojiMap): void

Adds new emoji mappings or overrides existing ones.

removeMappings(words: string[]): void

Removes emoji mappings for specific words.

getMappings(): EmojiMap

Returns the current emoji mappings.

resetToDefault(): void

Resets the emoji map to default mappings.

Types

type EmojiMap = {
  [key: string]: string;
};

License

MIT

1.0.1

11 months ago

1.0.0

11 months ago