diff --git a/types/node-emoji/index.d.ts b/types/node-emoji/index.d.ts index 52fc6fd6b9..5f4d050fb3 100644 --- a/types/node-emoji/index.d.ts +++ b/types/node-emoji/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for node-emoji 1.4 +// Type definitions for node-emoji 1.8 // Project: https://github.com/omnidan/node-emoji#readme // Definitions by: Tristan Jones +// styu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export const emoji: { @@ -1347,7 +1348,18 @@ export const emoji: { zzz: string; }; -export function emojify(str: string, on_missing?: (emoji_name: string) => string): string; +export interface Emoji { + emoji: string; + key: string; +} + +export function emojify(str: string, on_missing?: (emoji_name: string) => string, format?: (code: string, name: string) => string): string; export function get(emoji: string): string; -export function random(): string; +export function random(): Emoji; +export function search(searchTerm: string): Emoji[]; export function which(emoji_code: string): string; +export function unemojify(str: string): string; +export function find(emoji: string): Emoji; +export function hasEmoji(str: string): boolean; +export function strip(str: string): string; +export function replace(str: string, callback: (emoji: Emoji) => string): string; diff --git a/types/node-emoji/node-emoji-tests.ts b/types/node-emoji/node-emoji-tests.ts index 3bc883c6a4..918cb1e1f5 100644 --- a/types/node-emoji/node-emoji-tests.ts +++ b/types/node-emoji/node-emoji-tests.ts @@ -1,7 +1,8 @@ import emoji = require('node-emoji'); const coffee: string = emoji.get('coffee'); -const result: string = emoji.random(); +const result = emoji.random(); +const result_emoji: string = result.emoji; const cofee_name: string = emoji.which('☕️'); @@ -10,3 +11,17 @@ const emoji_string: string = emoji.emojify('I :heart: :coffee:! - :hushed::sta const emoji_string2: string = emoji.emojify('I :unknown_emoji: :star: :another_one:', (name: string) => name); const emoji_direct: string = emoji.emoji.coffee; + +const emoji_search = emoji.search('cof'); +const emojis_from_search: string[] = emoji_search.map(emoji => emoji.emoji); + +const unemojified_string: string = emoji.unemojify('I ❤️ 🍕'); + +const found_emoji = emoji.find('🍕'); +const found_emoji_string: string = found_emoji.emoji; + +const hasEmoji: boolean = emoji.hasEmoji('🍕'); + +const stripped_emoji: string = emoji.strip('⚠️ 〰️ 〰️ low disk space'); + +const replaced_emoji: string = emoji.replace('⚠️ 〰️ 〰️ low disk space', (emoji) => `${emoji.key}:`);