A base-N encoding/decoding library using colorful emojis. Convert numbers to memorable emoji sequences.
Note: This package uses 2,000 carefully selected colorful emojis that render properly across all platforms. Only emojis that display in full color (not undefined codepoints) are included.
The number of unique values that can be represented grows exponentially with the number of emojis (Base: 2,000):
| Emojis | Possible Combinations | Equivalent Bits |
|---|---|---|
| 1 Emoji | 2,000 | ~10.97 bits |
| 2 Emojis | 4.00 Million | ~21.93 bits |
| 3 Emojis | 8.00 Billion | ~32.90 bits |
| 4 Emojis | 16.0 Trillion | ~43.86 bits |
| 5 Emojis | 32.0 Quadrillion | ~54.83 bits |
| 6 Emojis | 64.0 Quintillion | ~65.79 bits |
| 7 Emojis | 128 Sextillion | ~76.76 bits |
| 8 Emojis | 256 Octillion | ~87.72 bits |
| 9 Emojis | 512 Nonillion | ~98.69 bits |
| 10 Emojis | 1.02 Decillion | ~109.66 bits |
| 11 Emojis | 2.05 Undecillion | ~120.62 bits |
| 12 Emojis | 4.10 Duodecillion | ~131.59 bits |
npx base2000 encode 2000
# Output: ๐๐
npx base2000 encode 38557435
# Output: ๐๐คน๐พ๐ฑ
npx base2000 encode 89752472641731123
# Output: ๐๐ค๐ฝ๐ฅ๐๐จ๐ฒ๐
npx base2000 encode 9875895267443635214141
# Output: ๐๐ด๐ผ๐ฏโ๏ธ๐ชข๐ก
npx base2000 encode 43785237458756783457242745611
# Output: ๐๐๐ฟ๐พ๐๐๐ฅพ๐ฆธ๐๐ปโผ๏ธ
npx base2000 encode 525421411452342311245233457643456
# Output: ๐๐ฟ๐ชโคต๏ธ๐ฅพ๐ฆ๐ฝ๐ฉ๐๐ป๐ซ๐ง๐ฟ- Encode/Decode Numbers: Convert numbers to base-2000 emoji representation
- BigInt Support: Handle arbitrarily large numbers
- Fast & Efficient: Optimized encoding/decoding algorithms
- TypeScript: Full TypeScript support with type definitions
- Visual & Fun: Use emojis for memorable identifiers
npm install base2000
# or
pnpm add base2000
# or
yarn add base2000# Using npx (no installation required)
npx base2000 encode 123456
npx base2000 decode "๐คฎ๐"
# After installation
base2000 encode 123456
base2000 decode "๐คฎ๐"import { encode, decode, getEmoji } from 'base2000';
// Basic encoding
encode(123456); // '๐คฎ๐'
decode('๐คฎ๐'); // 123456n
// Get emoji at specific index
getEmoji(0); // '๐'
getEmoji(20); // '๐'Encode a number to base-2000 emoji representation.
Important: For numbers larger than Number.MAX_SAFE_INTEGER (2^53-1), use BigInt or string to avoid precision loss.
encode(0); // '๐'
encode(2000); // '๐๐'
encode(123456); // '๐ฒ๐ถ๐ฝ'
encode(123456, ' '); // '๐ฒ ๐ถ๐ฝ' (custom separator)
// Large numbers - use string or BigInt
encode('373493284239852352787678'); // Works correctly
encode(373493284239852352787678n); // Same result
// Unsafe number will throw error
encode(9007199254740992); // โ Error: exceeds safe integer range
encode('9007199254740992'); // โ
Works correctlyDecode a base-2000 emoji representation back to a number.
decode('๐'); // 0n
decode('๐๐'); // 2000n
decode('๐ฒ๐ถ๐ฝ'); // 123456n
// With separator
decode('๐ฒ ๐ถ๐ฝ', ' '); // 123456n
decode('๐ฒ-๐ถ๐ฝ', '-'); // 123456nGet the emoji at a specific index (0-1999).
getEmoji(0); // '๐'
getEmoji(1); // '๐'
getEmoji(2); // '๐'Get the index of a specific emoji.
getEmojiIndex('๐'); // 0
getEmojiIndex('๐'); // 1
getEmojiIndex('๐'); // 2
getEmojiIndex('unknown'); // -1Get the total number of emojis in the base.
getBase(); // 2000The package includes a command-line interface for quick encoding/decoding.
# Global installation
npm install -g base2000
# Or use with npx (no installation required)
npx base2000 --help# Encode a number
base2000 encode <number> [options]
# Decode a string
base2000 decode <encoded> [options]--separator <sep>- Custom separator (default: none)-h, --help- Show help message
# Basic encoding
base2000 encode 123456
# Output: ๐คฎ๐
# Custom separator
base2000 encode 123456 --separator " "
# Output: ๐คฎ ๐
# Decoding
base2000 decode "๐คฎ๐"
# Output: 123456
# Decoding with separator
base2000 decode "๐คฎ ๐" --separator " "
# Output: 123456
# Large numbers
base2000 encode 987654321
# Output: ๐ฅณ๐ฅณ๐คช๐กimport { encode, decode } from 'base2000';
// Convert timestamp to memorable emoji identifier
const timestamp = Date.now();
const memorable = encode(timestamp);
console.log(`Session ID: ${memorable}`);
// Decode back to timestamp
const decoded = decode(memorable);import { encode } from 'base2000';
// Convert database ID to emoji-based short URL
const dbId = 123456789;
const shortCode = encode(dbId);
console.log(`Short URL: https://example.com/${shortCode}`);
// Output: https://example.com/๐๐ฅณ๐คช๐import { encode, decode } from 'base2000';
// Encode very large numbers
const largeNumber = '373493284239852352787678';
const encoded = encode(largeNumber);
console.log(encoded); // Emoji representation
const decoded = decode(encoded);
console.log(decoded); // 373493284239852352787678nBase2000 works like any positional numeral system (like binary, decimal, or hexadecimal), but uses 2000 as the base instead of 2, 10, or 16.
- Base-10 (Decimal): Uses digits 0-9
- Base-16 (Hexadecimal): Uses digits 0-9 and A-F
- Base-2000: Uses 2000 emojis
The number 123456 in base-2000:
123456 รท 2000 = 61 remainder 1456
61 รท 2000 = 0 remainder 61
Reading remainders from bottom to top: [61, 1456]
Emoji at index 61: (emoji at position 61)
Emoji at index 1456: (emoji at position 1456)
Result: (corresponding emoji sequence)
- Visual: Emojis are more visually distinctive than alphanumeric characters
- Memorable: Emoji sequences can be easier to remember
- Fun: Makes identifiers more engaging and user-friendly
- Compact: More efficient than base-64 for large numbers
The library is optimized for performance:
- Encoding/decoding operations complete in < 1ms for most numbers
- Supports BigInt for arbitrarily large numbers
- Efficient Map-based lookup for decoding
- Zero dependencies
Full TypeScript support with comprehensive type definitions:
import type { encode, decode } from 'base2000';
// All functions are fully typed
const encoded: string = encode(123456);
const decoded: bigint = decode(encoded);The library throws descriptive errors for invalid inputs:
encode(-1); // Error: Only non-negative numbers can be encoded
encode(3.14); // Error: Only integers can be encoded
decode(''); // Error: Encoded string cannot be empty
decode('invalid'); // Error: Invalid emoji in encoded string
getEmoji(3000); // Error: Index must be between 0 and 1999Works in all modern browsers and Node.js environments that support:
- ES2020+
- BigInt
- Unicode/Emoji support
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
hmmhmmhm
https://github.com/hmmhmmhm/node-packages/tree/main/packages/base2000