ordering

package module
v0.0.0-...-8e57a64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 2 Imported by: 1

README

📶 emoji-ordering

Utilities for ordering emojis according to the official Unicode emoji sort order

Go Report Card GoDoc

Installation

go get github.com/bcongdon/emoji-ordering

Usage

package main

import (
    "github.com/bcongdon/emoji-ordering"
    "fmt"
    "sort"
)

func main() {
    emojis := []string{"😎", "💯", "🤔", "🤷‍♂️", "🤷"}
    sort.Sort(ordering.EmojiSlice(emojis))
    fmt.Println(emojis)
    // [🤔, 😎, 💯, 🤷, 🤷‍♂️]

    fmt.Println(ordering.IsEmoji("🤷‍♂️"))
    // true

    fmt.Println(ordering.IsEmoji("foo"))
    // false

    fmt.Println(ordering.IsEmoji("😀 ")) // with extra whitespace
    // false

    // Constructing an Emoji Slice with Validation
    emojis = []string{"😎", "💯", "foo"}
    _, err := ordering.NewEmojiSlice(emojis)
    fmt.Println(err)
    // 'foo' is not an emoji
}

Documentation

Overview

Package ordering provides utilities for ordering emojis according to the official Unicode emoji sort order

Code generated by go generate; DO NOT EDIT. This file was generated at 2020-11-27 14:14:25.562605 -0800 PST m=+0.196019826 using data from http://unicode.org/emoji/charts/emoji-ordering.txt

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmoji

func IsEmoji(e string) bool

Types

type EmojiSlice

type EmojiSlice []string

func NewEmojiSlice

func NewEmojiSlice(emojis []string) (EmojiSlice, error)

func (EmojiSlice) Len

func (e EmojiSlice) Len() int

func (EmojiSlice) Less

func (e EmojiSlice) Less(a, b int) bool

func (EmojiSlice) Swap

func (e EmojiSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL