# Emoji Meanings & Data

## Description
This Node.js package fetches emoji data and meanings from the emoji.gg [unicode emojis](https://emoji.gg/meanings) API and caches it in a local JSON file. It allows searching, filtering, and retrieving emojis efficiently.

## Installation
```sh
npm install emoji-meanings
```

## Example Usage
```javascript
const emojiCache = require('emoji-meanings');

(async () => {
    await emojiCache.init(); // Ensure data is loaded
    
    console.log(emojiCache.search('smile'));  // Search emojis by name
    console.log(emojiCache.filterByCategory('tools'));  // Filter by category
    console.log(emojiCache.filterByVersion('16.0'));  // Filter by emoji version
    console.log(emojiCache.listAll());  // List all emojis
    console.log(emojiCache.getByUnicode('1F600'));  // Get emoji by Unicode
})();
```


## Example Data
```json
{
            "name": "root vegetable",
            "slug": "root-vegetable",
            "description": "The root vegetable emoji shows a round vegetable with leafy greens on top, representing different types of root vegetables like beets, radishes, and turnips. It is often used in discussions about healthy eating,... (<a href=\"https:\/\/emoji.gg\/meaning\/root-vegetable\">Read More<\/a>)",
            "category": "vegetables",
            "emoji_version": "16.0",
            "unicode": "U+1FADC",
            "character": "\ud83e\udedc"
        },
        {
            "name": "harp",
            "slug": "harp",
            "description": "The harp emoji shows a classic stringed musical instrument with an elegant, curved frame and a series of strings that produce beautiful sounds when played. This emoji is often seen in conversations related to music, peace... (<a href=\"https:\/\/emoji.gg\/meaning\/harp\">Read More<\/a>)",
            "category": "musical-instruments",
            "emoji_version": "16.0",
            "unicode": "U+1FA89",
            "character": "\ud83e\ude89"
        },
        {
            "name": "shovel",
            "slug": "shovel",
            "description": "The shovel emoji shows a simple tool that is used for digging, often in gardening, farming, or construction. This emoji symbolizes activities that involve breaking or moving soil, such as planting, landscaping, or start... (<a href=\"https:\/\/emoji.gg\/meaning\/shovel\">Read More<\/a>)",
            "category": "tools",
            "emoji_version": "16.0",
            "unicode": "U+1FA8F",
            "character": "\ud83e\ude8f"
        }
```

## Functions
- `init()` - Initializes the cache by fetching emoji data if needed.
- `search(query)` - Searches emojis by name (case insensitive).
- `filterByCategory(category)` - Filters emojis by category.
- `filterByVersion(version)` - Filters emojis by emoji version.
- `listAll()` - Returns all cached emojis.
- `getByUnicode(unicode)` - Retrieves an emoji by its Unicode value.

## Error Handling
This package includes error handling for:
- Failed API requests
- Corrupt cache files
- Invalid search queries

## License
This project is licensed under the MIT License.

