Emoshi (Emoshi v0.1.2)
View SourceLibrary for accessing the emoji data set.
Only fully qualified emojis (see https://www.unicode.org/reports/tr51/#def_fully_qualified_emoji) are included.
See https://www.unicode.org/reports/tr51/ for information about emojis.
Summary
Functions
Returns the closest emojis by slug.
Returns the codepoints for an emoji.
Returns whether a string is a single emoji
Returns the Emoshi.t/0
struct from the emoji character.
Returns all emojis for the given group.
Returns all emojis for the given groups.
Returns all emojis for the given group and subgroup(s).
Returns whether the input is an emoji group, case sensiive and exact match.
Returns all the emojis' groups
Returns all Emoshi.t/0
where the slug matches the input argument.
The function is case insensitive and normalizes whitespaces, tabs, etc. to hyphens.
Returns all the subgroups for a group, or nil
if the group does not exist.
Returns the unicode spec version used to generate the module.
Types
Functions
Returns the closest emojis by slug.
Uses String.jaro_distance/2
internally to find the closest emojis.
Options
:ignore_variations
-boolean/0
. Whether to ignore variations such as skin color. Defaults totrue
.:take
-pos_integer/0
. The number of emojis to retrieve. Defaults to5
Examples
iex> Emoshi.closest("tumbs up", take: 2)
[
%Emoshi{
slug: "thumbs-up",
name: "thumbs up",
status: :fully_qualified,
emoji: "👍",
group: "People & Body",
subgroup: "hand-fingers-closed"
},
%Emoshi{
slug: "thumbs-down",
name: "thumbs down",
status: :fully_qualified,
emoji: "👎",
group: "People & Body",
subgroup: "hand-fingers-closed"
}
]
Returns the codepoints for an emoji.
Examples
iex> Emoshi.codepoints("*️⃣")
"002A FE0F 20E3"
iex> Emoshi.codepoints("😌")
"1F60C"
Returns whether a string is a single emoji
Examples
iex> Emoshi.emoji?("❤️🔥")
true
iex> Emoshi.emoji?("a🫨")
false
Returns the Emoshi.t/0
struct from the emoji character.
Examples
iex> Emoshi.find_by_emoji("🥶")
%Emoshi{
name: "cold face",
status: :fully_qualified,
group: "Smileys & Emotion",
slug: "cold-face",
emoji: "🥶",
subgroup: "face-unwell"
}
iex> Emoshi.find_by_emoji("not an emoji")
nil
Returns all emojis for the given group.
Returns all emojis for the given groups.
Returns all emojis for the given group and subgroup(s).
Accepts both a single subgroup and a list of subgroups.
Examples
iex> Emoshi.for_subgroups("Smileys & Emotion", "face-hat") |> Enum.map(& &1.emoji)
["🤠", "🥳", "🥸"]
iex> Emoshi.for_subgroups("Smileys & Emotion", ["face-hat", "face-glasses"]) |> Enum.map(& &1.emoji)
["🤠", "🥳", "🥸", "😎", "🤓", "🧐"]
Returns whether the input is an emoji group, case sensiive and exact match.
Examples
iex> Emoshi.group?("Animals & Nature")
true
iex> Emoshi.group?("animals and nature")
false
@spec groups() :: [String.t()]
Returns all the emojis' groups
Returns all Emoshi.t/0
where the slug matches the input argument.
The function is case insensitive and normalizes whitespaces, tabs, etc. to hyphens.
Unlike closest/2
, it does not match emojis when there are spelling mistakes.
Options
:ignore_variations
-boolean/0
. Whether to ignore variations such as skin color. Defaults totrue
.:take
-pos_integer/0
. The maximum number of emojis to retrieve. Keep in mind that unlikeclosest/2
which always returns the specified:take
number, this function may return fewer results if there are not enough matches. Defaults to5
Examples
iex> Emoshi.search("thumbs up", take: 1)
[
%Emoshi{
slug: "thumbs-up",
name: "thumbs up",
status: :fully_qualified,
emoji: "👍",
group: "People & Body",
subgroup: "hand-fingers-closed"
}
]
iex> Emoshi.search("THUMBS-UP")
[
%Emoshi{
slug: "thumbs-up",
name: "thumbs up",
status: :fully_qualified,
emoji: "👍",
group: "People & Body",
subgroup: "hand-fingers-closed"
}
]
iex> Emoshi.search("tumbs-up")
[]
Returns all the subgroups for a group, or nil
if the group does not exist.
Examples
iex> Emoshi.subgroups("Flags")
["flag", "country-flag", "subdivision-flag"]
iex> Emoshi.subgroups("flags")
nil
@spec version() :: String.t()
Returns the unicode spec version used to generate the module.