CI License Version Docs

Emoshi

Elixir library for accessing emojis.

This library's list of emojis is generated from the official emoji data set

Installation

Add emoshi to your list of dependencies in mix.exs:

def deps do
  [
    {:emoshi, "~> 0.1.2"}
  ]
end

Basic usage

Searching by name

iex> Emoshi.search("thumbs", 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"
  }
]
iex> Emoshi.closest("tubms up", take: 1)
[
  %Emoshi{
    slug: "thumbs-up",
    name: "thumbs up",
    status: :fully_qualified,
    emoji: "👍",
    group: "People & Body",
    subgroup: "hand-fingers-closed"
  }
]

Query by group and subgroups

iex> Emoshi.for_subgroups("Travel & Places", "hotel")
[
  %Emoshi{
    slug: "bellhop-bell",
    name: "bellhop bell",
    status: :fully_qualified,
    emoji: "🛎️",
    group: "Travel & Places",
    subgroup: "hotel"
  },
  %Emoshi{
    slug: "luggage",
    name: "luggage",
    status: :fully_qualified,
    emoji: "🧳",
    group: "Travel & Places",
    subgroup: "hotel"
  }
]

Validation

iex> Emoshi.emoji("❤️‍🔥")
true

iex> Emoshi.emoji("hi")
false

Refer to the full documentation for a more comprehensive description of the library's functionality

Design and contributing

The main goal of this library is to provide the parsed emoji dataset as an Elixir package.

The approach of including the raw data set (either as text, json, or any format) and parsing it during runtime or during module compilation brings unnecessary dependencies and slows down application startup or application compilation times. This package aims to be as light as possible and currently contains no dependencies for production usage.

The reason to place the data module separately from the functionality module is simply to keep it IDE-friendly, since working on the main Emoshi module while having the entire emoji dataset in the same file would be slow and a poor developer experience.

Code generation

The full emoji dataset is downloaded from the official source via mix download_emojis. The file is then parsed and the data module is generated at Emoshi.Emoshis via mix generate_emojis. An alias is available to run these 2 tasks as mix download_and_generate.