From 515de0de45aa8a2a077fe3d844111d8a839a2141 Mon Sep 17 00:00:00 2001 From: Stephanie Yu Date: Sun, 10 Dec 2017 20:09:07 -0500 Subject: [PATCH 1/2] Update node-emoji types to 1.8.1 --- types/node-emoji/index.d.ts | 18 +++++++++++++++--- types/node-emoji/node-emoji-tests.ts | 15 ++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/types/node-emoji/index.d.ts b/types/node-emoji/index.d.ts index 52fc6fd6b9..f90c978346 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.1 // 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 IEmoji { + 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(): IEmoji; +export function search(searchTerm: string): IEmoji[]; export function which(emoji_code: string): string; +export function unemojify(str: string): string; +export function find(emoji: string): IEmoji; +export function hasEmoji(str: string): boolean; +export function strip(str: string): string; +export function replace(str: string, callback: (emoji: IEmoji) => string): string; diff --git a/types/node-emoji/node-emoji-tests.ts b/types/node-emoji/node-emoji-tests.ts index 3bc883c6a4..8b915afefe 100644 --- a/types/node-emoji/node-emoji-tests.ts +++ b/types/node-emoji/node-emoji-tests.ts @@ -1,7 +1,8 @@ +import { IEmoji } from "./index"; import emoji = require('node-emoji'); const coffee: string = emoji.get('coffee'); -const result: string = emoji.random(); +const result: IEmoji = emoji.random(); const cofee_name: string = emoji.which('☕️'); @@ -10,3 +11,15 @@ 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: IEmoji[] = emoji.search('cof'); + +const unemojified_string: string = emoji.unemojify('I ❤️ 🍕'); + +const found_emoji: IEmoji = emoji.find('🍕'); + +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}:`); From e315d9eb2809e6f50553eb53a9e52bbe08cac076 Mon Sep 17 00:00:00 2001 From: Stephanie Yu Date: Sun, 10 Dec 2017 21:15:11 -0500 Subject: [PATCH 2/2] Lint --- types/node-emoji/index.d.ts | 12 ++++++------ types/node-emoji/node-emoji-tests.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/types/node-emoji/index.d.ts b/types/node-emoji/index.d.ts index f90c978346..5f4d050fb3 100644 --- a/types/node-emoji/index.d.ts +++ b/types/node-emoji/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for node-emoji 1.8.1 +// Type definitions for node-emoji 1.8 // Project: https://github.com/omnidan/node-emoji#readme // Definitions by: Tristan Jones // styu @@ -1348,18 +1348,18 @@ export const emoji: { zzz: string; }; -export interface IEmoji { +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(): IEmoji; -export function search(searchTerm: string): IEmoji[]; +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): IEmoji; +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: IEmoji) => 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 8b915afefe..918cb1e1f5 100644 --- a/types/node-emoji/node-emoji-tests.ts +++ b/types/node-emoji/node-emoji-tests.ts @@ -1,8 +1,8 @@ -import { IEmoji } from "./index"; import emoji = require('node-emoji'); const coffee: string = emoji.get('coffee'); -const result: IEmoji = emoji.random(); +const result = emoji.random(); +const result_emoji: string = result.emoji; const cofee_name: string = emoji.which('☕️'); @@ -12,11 +12,13 @@ const emoji_string2: string = emoji.emojify('I :unknown_emoji: :star: :another_o const emoji_direct: string = emoji.emoji.coffee; -const emoji_search: IEmoji[] = emoji.search('cof'); +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: IEmoji = emoji.find('🍕'); +const found_emoji = emoji.find('🍕'); +const found_emoji_string: string = found_emoji.emoji; const hasEmoji: boolean = emoji.hasEmoji('🍕');