@neabyte/unicode-gen
v1.0.1
Published
A lightweight TypeScript library for generating random Unicode emojis with embedded data for instant offline usage
Maintainers
Readme
Unicode-Gen 🎲
A lightweight TypeScript library for generating random Unicode emojis. Features embedded Unicode data for instant offline usage with 3,781+ emojis across 100 categories.
✨ Features
- 🚀 Instant startup - No network requests, embedded data
- 📦 Offline ready - Works without internet connection
- 🎲 3,781+ emojis - Latest Unicode emoji data
- 📂 98 categories - Organized by emoji type
- ⚡ Lightweight - Minified browser bundle (~176KB, 26KB gzipped)
- 🔧 TypeScript - Full type safety and IntelliSense
- 🌐 Universal - Works in Node.js, browser, and standalone
- 🎯 Zero dependencies - No external files or network requests
📦 Installation
Node.js
npm install @neabyte/unicode-genBrowser
<!-- Via CDN -->
<script src="https://unpkg.com/@neabyte/unicode-gen@latest/dist/unicode-gen.min.js"></script>
<!-- Or download and include locally -->
<script src="path/to/unicode-gen.min.js"></script>
<!-- ES Modules -->
<script type="module">
import generator from 'https://unpkg.com/@neabyte/unicode-gen@latest/dist/unicode-gen.esm.js'
</script>🚀 Quick Start
Node.js
import generator from '@neabyte/unicode-gen'
// Get random emoji
generator.random() // '😀'Browser
// Access the global UnicodeGen object
const generator = UnicodeGen.default
// Get random emoji
generator.random() // '😀'Basic Examples
import generator from '@neabyte/unicode-gen'
// Get random emoji (default)
generator.random() // '😀'
// Get random emoji code
generator.random({ type: 'code' }) // '1F600'
// Get multiple random emojis
generator.random({ count: 5 }) // ['😀', '😃', '😄', '😁', '😆']
// Get from specific category
generator.random({ category: 'face-smiling' }) // '😀'
// Get full emoji object
generator.random({ type: 'both' }) // { code: '1F600', emoji: '😀' }🔧 API Reference
generator.random(options?: RandomOptions)
Generate random emojis with flexible options.
Options:
count?: number- Number of emojis to return (default: 1)category?: string- Specific category to choose fromtype?: 'code' | 'emoji' | 'both'- Return format (default: 'emoji')
Type Examples:
type: 'emoji'- Returns emoji characters (default)type: 'code'- Returns Unicode codestype: 'both'- Returns full objects with code and emoji
Returns:
- Single emoji:
stringorEmojiData - Multiple emojis:
string[]orEmojiData[]
generator.getCategories()
Returns array of available category names.
generator.getEmojisByCategory(category: string)
Returns all emojis in the specified category.
🚀 Advanced Usage
Standalone Usage
// Create your own instance
import { UnicodeGenerator } from '@neabyte/unicode-gen'
const generator = new UnicodeGenerator()
await generator.loadData()
// Use like normal
generator.random() // '😀'Category Management
// Get all available categories
const categories = generator.getCategories()
console.log(categories) // ['face-smiling', 'heart', 'animal-mammal', ...]
// Get all emojis from a category
const hearts = generator.getEmojisByCategory('heart')
console.log(hearts.length) // 25
console.log(hearts.map(e => e.emoji).join(' ')) // '💌 💘 💝 💖 💗 ...'Validation Examples
// Validate category exists
const categories = generator.getCategories()
if (categories.includes('face-smiling')) {
const emoji = generator.random({ category: 'face-smiling' })
}
// Handle invalid options
try {
generator.random({ count: 0 }) // Throws error
} catch (error) {
console.log('Invalid count:', error.message)
}📂 Available Categories
Your library includes 98 emoji categories:
😊 Faces & Emotions
face-smiling,face-affection,face-tongue,face-handface-neutral-skeptical,face-sleepy,face-unwellface-hat,face-glasses,face-concerned,face-negativeface-costume,cat-face,monkey-face,heart,emotion
🐾 Animals & Nature
animal-mammal,animal-bird,animal-amphibiananimal-reptile,animal-marine,animal-bugplant-flower,plant-other
🍕 Food & Drink
food-fruit,food-vegetable,food-preparedfood-asian,food-sweet,drink,dishware
🏠 Places & Transport
place-map,place-geographic,place-buildingplace-religious,place-othertransport-ground,transport-water,transport-air
👤 People & Activities
person,person-gesture,person-role,person-fantasyperson-activity,person-sport,person-restingfamily,person-symbol
🎮 Objects & Symbols
clothing,sound,music,musical-instrumentphone,computer,light-video,book-papermoney,mail,writing,office,lock,toolscience,medical,household,other-object
🚦 Signs & Symbols
transport-sign,warning,arrow,religion,zodiacav-symbol,gender,math,punctuation,currencyother-symbol,keycap,alphanum,geometric
🏁 Flags
flag,country-flag,subdivision-flag
📚 Documentation
For complete API reference and examples, see the full documentation.
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
MIT © NeaByteLab
