UNPKG

node-emojis

Version:

Modern, tree-shakeable emoji library for Node.js with TypeScript, search, skin tones, and aliases 🎉

119 lines 3.65 kB
/** Valid skin tone modifier names */ export type SkinTone = 'light' | 'medium-light' | 'medium' | 'medium-dark' | 'dark'; /** Numeric aliases for skin tones (1-5) */ export type SkinToneAlias = '1' | '2' | '3' | '4' | '5'; /** * Apply a skin tone modifier to an emoji * * This function removes any existing skin tone modifiers before applying the new one. * Supports both named tones ('light', 'medium-dark') and numeric aliases ('1', '4'). * * @param emoji - The emoji character to modify (e.g., '👋' or '👋🏻') * @param tone - The skin tone to apply (name or numeric alias) * @returns The emoji with the specified skin tone modifier applied * @throws {Error} If the tone parameter is invalid * * @example * ```typescript * // Apply skin tone by name * applySkinTone('👋', 'dark') * // Returns: '👋🏿' * * // Apply skin tone by numeric alias * applySkinTone('👋', '3') * // Returns: '👋🏽' (medium) * * // Replace existing skin tone * applySkinTone('👋🏻', 'dark') * // Returns: '👋🏿' * ``` */ export declare function applySkinTone(emoji: string, tone: SkinTone | SkinToneAlias): string; /** * Check if an emoji supports skin tone variations * * Works with both emoji names and emoji characters. Also checks aliases. * * @param nameOrEmoji - Either an emoji name (e.g., 'wave') or emoji character (e.g., '👋') * @returns true if the emoji supports skin tone modifiers, false otherwise * * @example * ```typescript * // Check by name * supportsSkinTone('wave') * // Returns: true * * // Check by emoji character * supportsSkinTone('👋') * // Returns: true * * // Check by alias * supportsSkinTone('hand_wave') * // Returns: true * * // Non-human emojis don't support skin tones * supportsSkinTone('fire') * // Returns: false * ``` */ export declare function supportsSkinTone(nameOrEmoji: string): boolean; /** * Get all skin tone variations of an emoji * * Returns an object with all possible skin tone variations including the default (no modifier). * * @param emoji - The emoji character to get variations for * @returns Object mapping tone names to emoji variations * * @example * ```typescript * getAllSkinToneVariations('👋') * // Returns: { * // default: '👋', * // light: '👋🏻', * // 'medium-light': '👋🏼', * // medium: '👋🏽', * // 'medium-dark': '👋🏾', * // dark: '👋🏿' * // } * * // Works with emojis that already have skin tone * getAllSkinToneVariations('👋🏻') * // Returns same as above (strips existing tone first) * ``` */ export declare function getAllSkinToneVariations(emoji: string): Record<SkinTone | 'default', string>; /** * Remove skin tone modifier from an emoji * * Strips all skin tone modifiers and variation selectors to return the base emoji. * Safe to use on emojis without skin tones. * * @param emoji - The emoji character to remove skin tone from * @returns The base emoji without any skin tone modifiers * * @example * ```typescript * // Remove skin tone * removeSkinTone('👋🏿') * // Returns: '👋' * * // Multiple skin tones (family emojis) * removeSkinTone('👨🏻‍👩🏾‍👧🏽') * // Returns: '👨‍👩‍👧' * * // No skin tone - returns unchanged * removeSkinTone('🔥') * // Returns: '🔥' * ``` */ export declare function removeSkinTone(emoji: string): string; export declare const SKIN_TONE_MODIFIERS: { light: string; "medium-light": string; medium: string; "medium-dark": string; dark: string; }; export declare const SKIN_TONE_CAPABLE_EMOJIS: string[]; //# sourceMappingURL=index.d.ts.map