UNPKG

node-emojis

Version:

Modern, tree-shakeable emoji library for Node.js with TypeScript, search, skin tones, and aliases πŸŽ‰

111 lines β€’ 2.97 kB
/** * Get emoji name from its character * * Performs a reverse lookup to find the canonical name of an emoji * given its character representation. * * @param emoji - The emoji character to look up * @returns The canonical name if found, undefined otherwise * * @example * ```typescript * // Find name from emoji * getNameFromEmoji('πŸ”₯') * // Returns: 'fire' * * // Unknown emoji returns undefined * getNameFromEmoji('πŸŒ€') * // Returns: undefined * * // Works with multi-character emojis * getNameFromEmoji('πŸ‘¨β€πŸ‘©β€πŸ‘§') * // Returns: 'family_man_woman_girl' * ``` */ export declare function getNameFromEmoji(emoji: string): string | undefined; /** * Get the complete reverse mapping * * Returns a frozen copy of the reverse emoji mapping (emoji β†’ name). * Useful for bulk operations or building custom lookup tables. * * @returns Read-only object mapping emoji characters to their names * * @example * ```typescript * const reverseMap = getReverseMapping() * // Returns: { * // 'πŸ”₯': 'fire', * // '😊': 'smile', * // 'πŸ‘': 'thumbsup', * // // ... all other emojis * // } * * // Use for lookups (read-only) * reverseMap['πŸ”₯'] // 'fire' * * // Attempting to modify throws error * reverseMap['πŸ”₯'] = 'flame' // TypeError: Cannot assign to read only property * ``` */ export declare function getReverseMapping(): Readonly<Record<string, string>>; /** * Check if a string is a valid emoji in the database * * Verifies whether a given string is a recognized emoji character * in the node-emojis database. * * @param str - The string to check * @returns true if the string is a known emoji, false otherwise * * @example * ```typescript * // Known emoji * isKnownEmoji('πŸ”₯') * // Returns: true * * // Unknown emoji * isKnownEmoji('πŸŒ€') * // Returns: false * * // Not an emoji * isKnownEmoji('hello') * // Returns: false * * // Works with complex emojis * isKnownEmoji('πŸ‘¨β€πŸ‘©β€πŸ‘§') * // Returns: true (if family emoji is in database) * ``` */ export declare function isKnownEmoji(str: string): boolean; /** * Create a reverse mapping from any emoji object * * Utility function to create a reverse lookup table from any * nameβ†’emoji mapping. Useful for working with custom emoji sets. * * @param emojiObject - Object mapping names to emoji characters * @returns New object mapping emoji characters to names * * @example * ```typescript * // Create reverse mapping from custom set * const customEmojis = { * happy: '😊', * sad: '😒', * fire: 'πŸ”₯' * } * * const reverseCustom = createReverseMapping(customEmojis) * // Returns: { * // '😊': 'happy', * // '😒': 'sad', * // 'πŸ”₯': 'fire' * // } * * // Use for lookups * reverseCustom['πŸ”₯'] // 'fire' * ``` */ export declare function createReverseMapping(emojiObject: Record<string, string>): Record<string, string>; //# sourceMappingURL=reverse-mapping.d.ts.map