diff --git a/src/emojify.ts b/src/emojify.ts index e1d41eb..0992fc1 100644 --- a/src/emojify.ts +++ b/src/emojify.ts @@ -10,10 +10,20 @@ export type EmojifyFormat = ( ) => string export interface EmojifyOptions { + /** + * The string to fallback to if an emoji was not found. + */ fallback?: ((part: string) => string) | string + + /** + * Adds a middleware layer to modify each matched emoji after parsing. + */ format?: EmojifyFormat } +/** + * Parse all markdown-encoded emojis in a string. + */ export const emojify = ( input: string, { fallback, format = name => name }: EmojifyOptions = {}, diff --git a/src/find.ts b/src/find.ts index 287b14e..537333b 100644 --- a/src/find.ts +++ b/src/find.ts @@ -1,6 +1,9 @@ import { findByCode } from './findByCode.js' import { findByName } from './findByName.js' +/** + * Get the name and character of an emoji. + */ export const find = (codeOrName: string) => { return findByCode(codeOrName) ?? findByName(codeOrName) } diff --git a/src/get.ts b/src/get.ts index 1a6ff0e..45ce18b 100644 --- a/src/get.ts +++ b/src/get.ts @@ -3,6 +3,9 @@ import { assert } from '@sindresorhus/is' import { emojiCodesByName } from './data.js' import { normalizeName } from './utils.js' +/** + * Get an emoji from an emoji name. + */ export const get = (codeOrName: string) => { assert.string(codeOrName) diff --git a/src/has.ts b/src/has.ts index 319ff08..63cb1d5 100644 --- a/src/has.ts +++ b/src/has.ts @@ -3,6 +3,9 @@ import { assert } from '@sindresorhus/is' import { emojiCodesByName, emojiNamesByCode } from './data.js' import { normalizeCode, normalizeName } from './utils.js' +/** + * Check if this library supports a specific emoji. + */ export const has = (codeOrName: string) => { assert.string(codeOrName) diff --git a/src/random.ts b/src/random.ts index 9ed4181..55750dc 100644 --- a/src/random.ts +++ b/src/random.ts @@ -1,6 +1,9 @@ import { emojiData } from './data.js' import { randomItem } from './utils.js' +/** + * Get a random emoji. + */ export const random = () => { const [name, emoji] = randomItem(emojiData) return { emoji, name } diff --git a/src/replace.ts b/src/replace.ts index 5ea5966..e11cc69 100644 --- a/src/replace.ts +++ b/src/replace.ts @@ -10,6 +10,9 @@ export type ReplaceReplacement = ( string: string, ) => string +/** + * Replace the emojis in a string. + */ export const replace = ( input: string, replacement: ReplaceReplacement | string, diff --git a/src/search.ts b/src/search.ts index 2366218..80f51f3 100644 --- a/src/search.ts +++ b/src/search.ts @@ -3,6 +3,9 @@ import { assert } from '@sindresorhus/is' import { emojiData } from './data.js' import { normalizeName } from './utils.js' +/** + * Search for emojis containing the provided name in their name. + */ export const search = (keyword: string) => { assert.string(keyword) diff --git a/src/strip.ts b/src/strip.ts index 7daa104..0f6202a 100644 --- a/src/strip.ts +++ b/src/strip.ts @@ -1,8 +1,14 @@ import { replace } from './replace.js' export interface StripOptions { + /** + * Whether to keep the extra space after a stripped emoji. + */ preserveSpaces?: boolean } +/** + * Remove all the emojis from a string. + */ export const strip = (input: string, { preserveSpaces }: StripOptions = {}) => replace(input, '', { preserveSpaces }) diff --git a/src/unemojify.ts b/src/unemojify.ts index 65238fa..4d96e4a 100644 --- a/src/unemojify.ts +++ b/src/unemojify.ts @@ -3,6 +3,9 @@ import { assert } from '@sindresorhus/is' import { charRegexMatcher } from './utils.js' import { which } from './which.js' +/** + * Convert all emojis in a string to their markdown-encoded counterparts. + */ export const unemojify = (input: string) => { assert.string(input) diff --git a/src/which.ts b/src/which.ts index 4698285..1ef0c67 100644 --- a/src/which.ts +++ b/src/which.ts @@ -7,6 +7,9 @@ export interface WhichOptions { markdown?: boolean } +/** + * Get an emoji name from an emoji. + */ export const which = ( emoji: string, { markdown = false }: WhichOptions = {},