1.1.2-4 • Published 5 years ago

simple-emoji-parser v1.1.2-4

Weekly downloads
12
License
Apache
Repository
github
Last release
5 years ago

Emoji Parser

This is just a simple emoji parser that I built to get more experience in writing npm packages. You can view it here: simple-emoji-parser

API

This is a very light-weight package, so there's not much to it.

Emoji | Interface

The main type that describes emojis.

interface Emoji {
    name?: string, // optional - unique naming
    id?: number, // optional - useful if you have duplicates
    trigger: string, // the trigger word
    url: string // the image URL to replace the trigger
}

The id parameter is totally optional and is only useful for duplicates and/or where you need to manually tamper with the Emojis array directly from the parser.

EmojiParser(emojis: Array<Emoji>) | Class

The central class of the package - where all the magic happens.

You need to initialize the class and pass the emojis array as a variable:

const parser = new EmojiParser(emojis);

Methods

parse(string: string, callback: (result: string) => void): void | Parse a message that may contain emoji triggers and will return the parsed string in a callback.

parseSync(string: string): Promise<string> | An asychronous method of the regular callback parse() method.

Variables

You can access the emojis array through the getters & setters in EmojiParser:

// Get all current emojis in the object
get emojis(): Array<Emoji> {
    return this._emojis;
}

// Replace all current emojis
set emojis(emoji: Array<Emoji>) {
    this._emojis = emoji;
}

Contributing

All contribution is done through the official GitHub Repository. As usual, create a branch, do your work, and make a pull request.

<3

1.1.2-4

5 years ago

1.1.2-3

5 years ago

1.1.2-2

5 years ago

1.1.2-1

5 years ago

1.1.2-0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.0-0

5 years ago

1.0.0

5 years ago