node-emojis 0.0.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -123
- package/lib/backward-compat.d.ts +29 -0
- package/lib/backward-compat.d.ts.map +1 -0
- package/lib/backward-compat.js +160 -0
- package/lib/backward-compat.js.map +1 -0
- package/lib/categories/animals.d.ts +3 -0
- package/lib/categories/animals.d.ts.map +1 -0
- package/lib/categories/animals.js +17 -0
- package/lib/categories/animals.js.map +1 -0
- package/lib/categories/food.d.ts +3 -0
- package/lib/categories/food.d.ts.map +1 -0
- package/lib/categories/food.js +17 -0
- package/lib/categories/food.js.map +1 -0
- package/lib/categories/nature.d.ts +3 -0
- package/lib/categories/nature.d.ts.map +1 -0
- package/lib/categories/nature.js +17 -0
- package/lib/categories/nature.js.map +1 -0
- package/lib/categories/people.d.ts +3 -0
- package/lib/categories/people.d.ts.map +1 -0
- package/lib/categories/people.js +17 -0
- package/lib/categories/people.js.map +1 -0
- package/lib/categories/travel.d.ts +3 -0
- package/lib/categories/travel.d.ts.map +1 -0
- package/lib/categories/travel.js +17 -0
- package/lib/categories/travel.js.map +1 -0
- package/lib/core/emoji.d.ts +46 -0
- package/lib/core/emoji.d.ts.map +1 -0
- package/lib/core/emoji.js +3 -0
- package/lib/core/emoji.js.map +1 -0
- package/lib/data/aliases.json +472 -0
- package/lib/data/categories.json +381 -0
- package/lib/data/emojis.json +371 -0
- package/lib/data/metadata.json +3254 -0
- package/lib/data/skin-tones.json +196 -0
- package/lib/features/aliases/index.d.ts +375 -0
- package/lib/features/aliases/index.d.ts.map +1 -0
- package/lib/features/aliases/index.js +230 -0
- package/lib/features/aliases/index.js.map +1 -0
- package/lib/features/filters/index.d.ts +119 -0
- package/lib/features/filters/index.d.ts.map +1 -0
- package/lib/features/filters/index.js +196 -0
- package/lib/features/filters/index.js.map +1 -0
- package/lib/features/search/index.d.ts +82 -0
- package/lib/features/search/index.d.ts.map +1 -0
- package/lib/features/search/index.js +204 -0
- package/lib/features/search/index.js.map +1 -0
- package/lib/features/skin-tones/index.d.ts +119 -0
- package/lib/features/skin-tones/index.d.ts.map +1 -0
- package/lib/features/skin-tones/index.js +184 -0
- package/lib/features/skin-tones/index.js.map +1 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +57 -3
- package/lib/index.js.map +1 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/reverse-mapping.d.ts +111 -0
- package/lib/utils/reverse-mapping.d.ts.map +1 -0
- package/lib/utils/reverse-mapping.js +138 -0
- package/lib/utils/reverse-mapping.js.map +1 -0
- package/lib/utils/validators.d.ts +63 -0
- package/lib/utils/validators.d.ts.map +1 -0
- package/lib/utils/validators.js +106 -0
- package/lib/utils/validators.js.map +1 -0
- package/package.json +121 -17
- package/.github/FUNDING.yml +0 -5
- package/.github/workflows/nodejs.yml +0 -26
- package/.travis.yml +0 -12
- package/CODE_OF_CONDUCT.md +0 -46
- package/lib/emojis/animal-emojis.js +0 -71
- package/lib/emojis/emojis.js +0 -9
- package/lib/emojis/food-emojis.js +0 -42
- package/lib/emojis/index.js +0 -3
- package/lib/emojis/nature-emojis.js +0 -9
- package/lib/emojis/people-emojis.js +0 -181
- package/lib/emojis/travel-emojis.js +0 -17
- package/test/test.js +0 -26
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.aliases = void 0;
|
|
7
|
+
exports.getAliases = getAliases;
|
|
8
|
+
exports.getPrimaryName = getPrimaryName;
|
|
9
|
+
exports.isSameEmoji = isSameEmoji;
|
|
10
|
+
exports.getAllNames = getAllNames;
|
|
11
|
+
exports.resolveEmoji = resolveEmoji;
|
|
12
|
+
exports.getAliasMap = getAliasMap;
|
|
13
|
+
const aliases_json_1 = __importDefault(require("../../data/aliases.json"));
|
|
14
|
+
const emojis_json_1 = __importDefault(require("../../data/emojis.json"));
|
|
15
|
+
/**
|
|
16
|
+
* Raw alias data mapping primary names to their aliases
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* aliases['smile'] // ['happy', 'joy', 'pleased']
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
exports.aliases = aliases_json_1.default;
|
|
23
|
+
/**
|
|
24
|
+
* Get all aliases for an emoji name
|
|
25
|
+
*
|
|
26
|
+
* Returns different results based on the input:
|
|
27
|
+
* - If given a primary name: returns its aliases
|
|
28
|
+
* - If given an alias: returns the primary name and other aliases
|
|
29
|
+
* - If given an unknown name: returns empty array
|
|
30
|
+
*
|
|
31
|
+
* @param name - The emoji name or alias to look up
|
|
32
|
+
* @returns Array of aliases (excluding the input name itself)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Get aliases for a primary name
|
|
37
|
+
* getAliases('smile')
|
|
38
|
+
* // Returns: ['happy', 'joy', 'pleased']
|
|
39
|
+
*
|
|
40
|
+
* // Get related names when given an alias
|
|
41
|
+
* getAliases('happy') // (assuming 'happy' is an alias of 'smile')
|
|
42
|
+
* // Returns: ['smile', 'joy', 'pleased']
|
|
43
|
+
*
|
|
44
|
+
* // Unknown name returns empty array
|
|
45
|
+
* getAliases('unknown')
|
|
46
|
+
* // Returns: []
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
function getAliases(name) {
|
|
50
|
+
// Check if this is a primary name with aliases
|
|
51
|
+
if (aliases_json_1.default[name]) {
|
|
52
|
+
return aliases_json_1.default[name];
|
|
53
|
+
}
|
|
54
|
+
// Check if this is an alias itself
|
|
55
|
+
const primaryName = getPrimaryName(name);
|
|
56
|
+
if (primaryName !== name && aliases_json_1.default[primaryName]) {
|
|
57
|
+
return [primaryName, ...aliases_json_1.default[primaryName].filter(a => a !== name)];
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get the primary name for an emoji (resolves aliases)
|
|
63
|
+
*
|
|
64
|
+
* This function normalizes emoji names by resolving aliases to their primary names.
|
|
65
|
+
* If the input is already a primary name or is unknown, it returns the input unchanged.
|
|
66
|
+
*
|
|
67
|
+
* @param name - The emoji name or alias to resolve
|
|
68
|
+
* @returns The primary name if found, otherwise returns the input unchanged
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // Already a primary name
|
|
73
|
+
* getPrimaryName('smile')
|
|
74
|
+
* // Returns: 'smile'
|
|
75
|
+
*
|
|
76
|
+
* // Resolve an alias
|
|
77
|
+
* getPrimaryName('happy') // (assuming 'happy' is an alias of 'smile')
|
|
78
|
+
* // Returns: 'smile'
|
|
79
|
+
*
|
|
80
|
+
* // Unknown name returns unchanged
|
|
81
|
+
* getPrimaryName('unknown')
|
|
82
|
+
* // Returns: 'unknown'
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
function getPrimaryName(name) {
|
|
86
|
+
// Check if this is already a primary name
|
|
87
|
+
if (aliases_json_1.default[name]) {
|
|
88
|
+
return name;
|
|
89
|
+
}
|
|
90
|
+
// Find if this is an alias
|
|
91
|
+
for (const [primary, aliasList] of Object.entries(aliases_json_1.default)) {
|
|
92
|
+
if (aliasList.includes(name)) {
|
|
93
|
+
return primary;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if two names refer to the same emoji
|
|
100
|
+
*
|
|
101
|
+
* Compares two emoji names/aliases by resolving them to their primary names.
|
|
102
|
+
* Useful for deduplication and equivalence checking.
|
|
103
|
+
*
|
|
104
|
+
* @param name1 - First emoji name or alias
|
|
105
|
+
* @param name2 - Second emoji name or alias
|
|
106
|
+
* @returns true if both names refer to the same emoji, false otherwise
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Same primary name
|
|
111
|
+
* isSameEmoji('smile', 'smile')
|
|
112
|
+
* // Returns: true
|
|
113
|
+
*
|
|
114
|
+
* // Primary name vs alias
|
|
115
|
+
* isSameEmoji('smile', 'happy') // (assuming 'happy' is an alias of 'smile')
|
|
116
|
+
* // Returns: true
|
|
117
|
+
*
|
|
118
|
+
* // Two different aliases of the same emoji
|
|
119
|
+
* isSameEmoji('happy', 'joy') // (both aliases of 'smile')
|
|
120
|
+
* // Returns: true
|
|
121
|
+
*
|
|
122
|
+
* // Different emojis
|
|
123
|
+
* isSameEmoji('smile', 'fire')
|
|
124
|
+
* // Returns: false
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
function isSameEmoji(name1, name2) {
|
|
128
|
+
const primary1 = getPrimaryName(name1);
|
|
129
|
+
const primary2 = getPrimaryName(name2);
|
|
130
|
+
return primary1 === primary2;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get all names (primary + aliases) for an emoji
|
|
134
|
+
*
|
|
135
|
+
* Returns a complete list of all names that can be used to refer to an emoji,
|
|
136
|
+
* including both the primary name and all its aliases.
|
|
137
|
+
*
|
|
138
|
+
* @param name - Any name or alias for the emoji
|
|
139
|
+
* @returns Array with primary name first, followed by all aliases
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* // Get all names starting from primary name
|
|
144
|
+
* getAllNames('smile')
|
|
145
|
+
* // Returns: ['smile', 'happy', 'joy', 'pleased']
|
|
146
|
+
*
|
|
147
|
+
* // Get all names starting from an alias
|
|
148
|
+
* getAllNames('happy') // (assuming 'happy' is an alias of 'smile')
|
|
149
|
+
* // Returns: ['smile', 'happy', 'joy', 'pleased']
|
|
150
|
+
*
|
|
151
|
+
* // Unknown name returns just that name
|
|
152
|
+
* getAllNames('unknown')
|
|
153
|
+
* // Returns: ['unknown']
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
function getAllNames(name) {
|
|
157
|
+
const primaryName = getPrimaryName(name);
|
|
158
|
+
const aliases = getAliases(primaryName);
|
|
159
|
+
return [primaryName, ...aliases];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Resolve an emoji name or alias to its character
|
|
163
|
+
*
|
|
164
|
+
* Looks up an emoji character by name, automatically handling alias resolution.
|
|
165
|
+
* This is the recommended way to get emoji characters as it handles both
|
|
166
|
+
* primary names and aliases transparently.
|
|
167
|
+
*
|
|
168
|
+
* @param nameOrAlias - The emoji name or alias to resolve
|
|
169
|
+
* @returns The emoji character if found, undefined otherwise
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Resolve by primary name
|
|
174
|
+
* resolveEmoji('fire')
|
|
175
|
+
* // Returns: '🔥'
|
|
176
|
+
*
|
|
177
|
+
* // Resolve by alias
|
|
178
|
+
* resolveEmoji('flame') // (assuming 'flame' is an alias of 'fire')
|
|
179
|
+
* // Returns: '🔥'
|
|
180
|
+
*
|
|
181
|
+
* // Unknown name returns undefined
|
|
182
|
+
* resolveEmoji('unknown')
|
|
183
|
+
* // Returns: undefined
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
function resolveEmoji(nameOrAlias) {
|
|
187
|
+
// Try direct lookup
|
|
188
|
+
if (emojis_json_1.default[nameOrAlias]) {
|
|
189
|
+
return emojis_json_1.default[nameOrAlias];
|
|
190
|
+
}
|
|
191
|
+
// Try resolving as alias
|
|
192
|
+
const primaryName = getPrimaryName(nameOrAlias);
|
|
193
|
+
return emojis_json_1.default[primaryName];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get a map of all aliases to their primary names
|
|
197
|
+
*
|
|
198
|
+
* Builds and returns a reverse mapping from aliases to their primary names.
|
|
199
|
+
* Useful for bulk operations or building lookup tables.
|
|
200
|
+
* Note: This generates a new object each time, so cache the result if using repeatedly.
|
|
201
|
+
*
|
|
202
|
+
* @returns Object mapping each alias to its primary emoji name
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const aliasMap = getAliasMap()
|
|
207
|
+
* // Returns: {
|
|
208
|
+
* // 'happy': 'smile',
|
|
209
|
+
* // 'joy': 'smile',
|
|
210
|
+
* // 'pleased': 'smile',
|
|
211
|
+
* // 'flame': 'fire',
|
|
212
|
+
* // 'blaze': 'fire',
|
|
213
|
+
* // // ... all other aliases
|
|
214
|
+
* // }
|
|
215
|
+
*
|
|
216
|
+
* // Use for quick lookups
|
|
217
|
+
* aliasMap['happy'] // 'smile'
|
|
218
|
+
* aliasMap['flame'] // 'fire'
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
function getAliasMap() {
|
|
222
|
+
const map = {};
|
|
223
|
+
Object.entries(aliases_json_1.default).forEach(([primary, aliasList]) => {
|
|
224
|
+
aliasList.forEach(alias => {
|
|
225
|
+
map[alias] = primary;
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
return map;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/aliases/index.ts"],"names":[],"mappings":";;;;;;AAsCA,gCAaC;AA0BD,wCAcC;AA+BD,kCAIC;AA0BD,kCAKC;AA2BD,oCASC;AA4BD,kCAUC;AAvOD,2EAA+C;AAC/C,yEAA2C;AAE3C;;;;;;GAMG;AACU,QAAA,OAAO,GAAG,sBAAS,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,+CAA+C;IAC/C,IAAI,sBAAS,CAAC,IAA8B,CAAC,EAAE,CAAC;Q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W,CAAC,CAAA;IAEvC,OAAO,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,YAAY,CAAC,WAAmB;IAC9C,oBAAoB;IACpB,IAAI,qBAAM,CAAC,WAAkC,CAAC,EAAE,CAAC;QAC/C,OAAO,qBAAM,CAAC,WAAkC,CAAC,CAAA;IACnD,CAAC;IAED,yBAAyB;IACzB,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,CAAA;IAC/C,OAAO,qBAAM,CAAC,WAAkC,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,WAAW;IACzB,MAAM,GAAG,GAA2B,EAAE,CAAA;IAEtC,MAAM,CAAC,OAAO,CAAC,sBAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE;QACzD,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAA;QACtB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import categories from '../../data/categories.json';
|
|
2
|
+
/**
|
|
3
|
+
* Complete information about an emoji including metadata
|
|
4
|
+
*/
|
|
5
|
+
export interface EmojiInfo {
|
|
6
|
+
/** The canonical name of the emoji */
|
|
7
|
+
name: string;
|
|
8
|
+
/** The emoji character */
|
|
9
|
+
emoji: string;
|
|
10
|
+
/** The category this emoji belongs to */
|
|
11
|
+
category: string;
|
|
12
|
+
/** Array of keywords for searching */
|
|
13
|
+
keywords: string[];
|
|
14
|
+
/** The Unicode version when this emoji was introduced */
|
|
15
|
+
unicodeVersion: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Filter emojis by category
|
|
19
|
+
*
|
|
20
|
+
* Returns all emojis that belong to a specific category.
|
|
21
|
+
* Categories are predefined groups like 'people', 'animals', 'food', etc.
|
|
22
|
+
*
|
|
23
|
+
* @param category - The category name to filter by
|
|
24
|
+
* @returns Array of emoji info objects for the specified category
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Get all people emojis
|
|
29
|
+
* filterByCategory('people')
|
|
30
|
+
* // Returns: [
|
|
31
|
+
* // { name: 'smile', emoji: '😊', category: 'people', ... },
|
|
32
|
+
* // { name: 'laugh', emoji: '😂', category: 'people', ... },
|
|
33
|
+
* // ...
|
|
34
|
+
* // ]
|
|
35
|
+
*
|
|
36
|
+
* // Invalid category returns empty array
|
|
37
|
+
* filterByCategory('invalid' as any)
|
|
38
|
+
* // Returns: []
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function filterByCategory(category: keyof typeof categories): EmojiInfo[];
|
|
42
|
+
/**
|
|
43
|
+
* Filter emojis by Unicode version
|
|
44
|
+
*
|
|
45
|
+
* Find emojis based on when they were introduced in the Unicode standard.
|
|
46
|
+
* Useful for ensuring compatibility with older systems.
|
|
47
|
+
*
|
|
48
|
+
* @param version - The Unicode version to filter by (e.g., '13.0', '15.0')
|
|
49
|
+
* @param comparison - How to compare versions:
|
|
50
|
+
* - 'exact': Only emojis from this exact version
|
|
51
|
+
* - 'min': Emojis from this version or newer (default)
|
|
52
|
+
* - 'max': Emojis from this version or older
|
|
53
|
+
* @returns Array of emoji info objects matching the version criteria
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Get emojis introduced in Unicode 13.0
|
|
58
|
+
* filterByVersion('13.0', 'exact')
|
|
59
|
+
* // Returns: [{ name: 'ninja', emoji: '🥷', unicodeVersion: '13.0', ... }]
|
|
60
|
+
*
|
|
61
|
+
* // Get all emojis available in Unicode 12.0 or earlier
|
|
62
|
+
* filterByVersion('12.0', 'max')
|
|
63
|
+
* // Returns: All emojis with unicodeVersion <= '12.0'
|
|
64
|
+
*
|
|
65
|
+
* // Get modern emojis (13.0+)
|
|
66
|
+
* filterByVersion('13.0', 'min')
|
|
67
|
+
* // Returns: All emojis with unicodeVersion >= '13.0'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function filterByVersion(version: string, comparison?: 'exact' | 'min' | 'max'): EmojiInfo[];
|
|
71
|
+
/**
|
|
72
|
+
* Filter emojis by keyword
|
|
73
|
+
*
|
|
74
|
+
* Find emojis that have a specific keyword in their metadata.
|
|
75
|
+
* Keywords are descriptive terms associated with each emoji for searching.
|
|
76
|
+
*
|
|
77
|
+
* @param keyword - The keyword to search for
|
|
78
|
+
* @param exact - If true, requires exact keyword match. If false, allows partial matches (default)
|
|
79
|
+
* @returns Array of emoji info objects with matching keywords
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Find emojis with 'happy' keyword (partial match)
|
|
84
|
+
* filterByKeyword('happy')
|
|
85
|
+
* // Returns: Emojis with keywords containing 'happy'
|
|
86
|
+
*
|
|
87
|
+
* // Find emojis with exact 'love' keyword
|
|
88
|
+
* filterByKeyword('love', true)
|
|
89
|
+
* // Returns: Only emojis with exact keyword 'love', not 'lovely' or 'glove'
|
|
90
|
+
*
|
|
91
|
+
* // Case-insensitive search
|
|
92
|
+
* filterByKeyword('HAPPY')
|
|
93
|
+
* // Returns: Same as filterByKeyword('happy')
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function filterByKeyword(keyword: string, exact?: boolean): EmojiInfo[];
|
|
97
|
+
/**
|
|
98
|
+
* Get all available Unicode versions
|
|
99
|
+
*
|
|
100
|
+
* Returns a list of all Unicode versions that have emojis in the dataset,
|
|
101
|
+
* sorted from oldest to newest.
|
|
102
|
+
*
|
|
103
|
+
* @returns Sorted array of Unicode version strings
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* getUnicodeVersions()
|
|
108
|
+
* // Returns: ['1.0', '3.0', '6.0', '11.0', '12.0', '13.0', '14.0', '15.0']
|
|
109
|
+
*
|
|
110
|
+
* // Use with filterByVersion to get emojis per version
|
|
111
|
+
* const versions = getUnicodeVersions()
|
|
112
|
+
* versions.forEach(v => {
|
|
113
|
+
* const emojis = filterByVersion(v, 'exact')
|
|
114
|
+
* console.log(`Unicode ${v}: ${emojis.length} emojis`)
|
|
115
|
+
* })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function getUnicodeVersions(): string[];
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/filters/index.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,4BAA4B,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAA;IAChB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,OAAO,UAAU,GAAG,SAAS,EAAE,CAa/E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,OAAO,GAAG,KAAK,GAAG,KAAa,GAAG,SAAS,EAAE,CAgCzG;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,SAAS,EAAE,CAwB3E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAU7C"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.filterByCategory = filterByCategory;
|
|
7
|
+
exports.filterByVersion = filterByVersion;
|
|
8
|
+
exports.filterByKeyword = filterByKeyword;
|
|
9
|
+
exports.getUnicodeVersions = getUnicodeVersions;
|
|
10
|
+
const emojis_json_1 = __importDefault(require("../../data/emojis.json"));
|
|
11
|
+
const metadata_json_1 = __importDefault(require("../../data/metadata.json"));
|
|
12
|
+
const categories_json_1 = __importDefault(require("../../data/categories.json"));
|
|
13
|
+
/**
|
|
14
|
+
* Filter emojis by category
|
|
15
|
+
*
|
|
16
|
+
* Returns all emojis that belong to a specific category.
|
|
17
|
+
* Categories are predefined groups like 'people', 'animals', 'food', etc.
|
|
18
|
+
*
|
|
19
|
+
* @param category - The category name to filter by
|
|
20
|
+
* @returns Array of emoji info objects for the specified category
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Get all people emojis
|
|
25
|
+
* filterByCategory('people')
|
|
26
|
+
* // Returns: [
|
|
27
|
+
* // { name: 'smile', emoji: '😊', category: 'people', ... },
|
|
28
|
+
* // { name: 'laugh', emoji: '😂', category: 'people', ... },
|
|
29
|
+
* // ...
|
|
30
|
+
* // ]
|
|
31
|
+
*
|
|
32
|
+
* // Invalid category returns empty array
|
|
33
|
+
* filterByCategory('invalid' as any)
|
|
34
|
+
* // Returns: []
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function filterByCategory(category) {
|
|
38
|
+
const emojiNames = categories_json_1.default[category] || [];
|
|
39
|
+
return emojiNames.map(name => {
|
|
40
|
+
const meta = metadata_json_1.default[name];
|
|
41
|
+
return {
|
|
42
|
+
name,
|
|
43
|
+
emoji: emojis_json_1.default[name],
|
|
44
|
+
category: meta?.category || category,
|
|
45
|
+
keywords: meta?.keywords || [],
|
|
46
|
+
unicodeVersion: meta?.unicodeVersion || '1.0'
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Filter emojis by Unicode version
|
|
52
|
+
*
|
|
53
|
+
* Find emojis based on when they were introduced in the Unicode standard.
|
|
54
|
+
* Useful for ensuring compatibility with older systems.
|
|
55
|
+
*
|
|
56
|
+
* @param version - The Unicode version to filter by (e.g., '13.0', '15.0')
|
|
57
|
+
* @param comparison - How to compare versions:
|
|
58
|
+
* - 'exact': Only emojis from this exact version
|
|
59
|
+
* - 'min': Emojis from this version or newer (default)
|
|
60
|
+
* - 'max': Emojis from this version or older
|
|
61
|
+
* @returns Array of emoji info objects matching the version criteria
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Get emojis introduced in Unicode 13.0
|
|
66
|
+
* filterByVersion('13.0', 'exact')
|
|
67
|
+
* // Returns: [{ name: 'ninja', emoji: '🥷', unicodeVersion: '13.0', ... }]
|
|
68
|
+
*
|
|
69
|
+
* // Get all emojis available in Unicode 12.0 or earlier
|
|
70
|
+
* filterByVersion('12.0', 'max')
|
|
71
|
+
* // Returns: All emojis with unicodeVersion <= '12.0'
|
|
72
|
+
*
|
|
73
|
+
* // Get modern emojis (13.0+)
|
|
74
|
+
* filterByVersion('13.0', 'min')
|
|
75
|
+
* // Returns: All emojis with unicodeVersion >= '13.0'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
function filterByVersion(version, comparison = 'min') {
|
|
79
|
+
const results = [];
|
|
80
|
+
Object.entries(emojis_json_1.default).forEach(([name, emoji]) => {
|
|
81
|
+
const meta = metadata_json_1.default[name];
|
|
82
|
+
const emojiVersion = meta?.unicodeVersion || '1.0';
|
|
83
|
+
let include = false;
|
|
84
|
+
switch (comparison) {
|
|
85
|
+
case 'exact':
|
|
86
|
+
include = emojiVersion === version;
|
|
87
|
+
break;
|
|
88
|
+
case 'min':
|
|
89
|
+
include = compareVersions(emojiVersion, version) >= 0;
|
|
90
|
+
break;
|
|
91
|
+
case 'max':
|
|
92
|
+
include = compareVersions(emojiVersion, version) <= 0;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (include) {
|
|
96
|
+
results.push({
|
|
97
|
+
name,
|
|
98
|
+
emoji: emoji,
|
|
99
|
+
category: meta?.category || 'other',
|
|
100
|
+
keywords: meta?.keywords || [],
|
|
101
|
+
unicodeVersion: emojiVersion
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return results;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Filter emojis by keyword
|
|
109
|
+
*
|
|
110
|
+
* Find emojis that have a specific keyword in their metadata.
|
|
111
|
+
* Keywords are descriptive terms associated with each emoji for searching.
|
|
112
|
+
*
|
|
113
|
+
* @param keyword - The keyword to search for
|
|
114
|
+
* @param exact - If true, requires exact keyword match. If false, allows partial matches (default)
|
|
115
|
+
* @returns Array of emoji info objects with matching keywords
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // Find emojis with 'happy' keyword (partial match)
|
|
120
|
+
* filterByKeyword('happy')
|
|
121
|
+
* // Returns: Emojis with keywords containing 'happy'
|
|
122
|
+
*
|
|
123
|
+
* // Find emojis with exact 'love' keyword
|
|
124
|
+
* filterByKeyword('love', true)
|
|
125
|
+
* // Returns: Only emojis with exact keyword 'love', not 'lovely' or 'glove'
|
|
126
|
+
*
|
|
127
|
+
* // Case-insensitive search
|
|
128
|
+
* filterByKeyword('HAPPY')
|
|
129
|
+
* // Returns: Same as filterByKeyword('happy')
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
function filterByKeyword(keyword, exact = false) {
|
|
133
|
+
const searchTerm = keyword.toLowerCase();
|
|
134
|
+
const results = [];
|
|
135
|
+
Object.entries(emojis_json_1.default).forEach(([name, emoji]) => {
|
|
136
|
+
const meta = metadata_json_1.default[name];
|
|
137
|
+
const keywords = meta?.keywords || [];
|
|
138
|
+
const match = exact
|
|
139
|
+
? keywords.some(k => k.toLowerCase() === searchTerm)
|
|
140
|
+
: keywords.some(k => k.toLowerCase().includes(searchTerm));
|
|
141
|
+
if (match) {
|
|
142
|
+
results.push({
|
|
143
|
+
name,
|
|
144
|
+
emoji: emoji,
|
|
145
|
+
category: meta?.category || 'other',
|
|
146
|
+
keywords,
|
|
147
|
+
unicodeVersion: meta?.unicodeVersion || '1.0'
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return results;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get all available Unicode versions
|
|
155
|
+
*
|
|
156
|
+
* Returns a list of all Unicode versions that have emojis in the dataset,
|
|
157
|
+
* sorted from oldest to newest.
|
|
158
|
+
*
|
|
159
|
+
* @returns Sorted array of Unicode version strings
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* getUnicodeVersions()
|
|
164
|
+
* // Returns: ['1.0', '3.0', '6.0', '11.0', '12.0', '13.0', '14.0', '15.0']
|
|
165
|
+
*
|
|
166
|
+
* // Use with filterByVersion to get emojis per version
|
|
167
|
+
* const versions = getUnicodeVersions()
|
|
168
|
+
* versions.forEach(v => {
|
|
169
|
+
* const emojis = filterByVersion(v, 'exact')
|
|
170
|
+
* console.log(`Unicode ${v}: ${emojis.length} emojis`)
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
function getUnicodeVersions() {
|
|
175
|
+
const versions = new Set();
|
|
176
|
+
Object.values(metadata_json_1.default).forEach(meta => {
|
|
177
|
+
if (meta?.unicodeVersion) {
|
|
178
|
+
versions.add(meta.unicodeVersion);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return Array.from(versions).sort(compareVersions);
|
|
182
|
+
}
|
|
183
|
+
// Helper function to compare version strings
|
|
184
|
+
function compareVersions(a, b) {
|
|
185
|
+
const partsA = a.split('.').map(Number);
|
|
186
|
+
const partsB = b.split('.').map(Number);
|
|
187
|
+
for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
|
|
188
|
+
const partA = partsA[i] || 0;
|
|
189
|
+
const partB = partsB[i] || 0;
|
|
190
|
+
if (partA !== partB) {
|
|
191
|
+
return partA - partB;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/filters/index.ts"],"names":[],"mappings":";;;;;AA4CA,4CAaC;AA8BD,0CAgCC;AA2BD,0CAwBC;AAuBD,gDAUC;AA3MD,yEAA2C;AAC3C,6EAA+C;AAC/C,iFAAmD;AAkBnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,gBAAgB,CAAC,QAAiC;IAChE,MAAM,UAAU,GAAG,yBAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAA;IAE7C,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,IAAI,GAAG,uBAAQ,CAAC,IAA6B,CAAC,CAAA;QACpD,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,qBAAM,CAAC,IAA2B,CAAC;YAC1C,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,QAAQ;YACpC,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,EAAE;YAC9B,cAAc,EAAE,IAAI,EAAE,cAAc,IAAI,KAAK;SAC9C,CAAA;IACH,CAAC,C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D,CAAC;AAED,6CAA6C;AAC7C,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS;IAC3C,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACvC,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAE5B,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACpB,OAAO,KAAK,GAAG,KAAK,CAAA;QACtB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a search result for emoji queries
|
|
3
|
+
*/
|
|
4
|
+
export interface SearchResult {
|
|
5
|
+
/** The canonical name of the emoji (e.g., 'fire', 'smile') */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The actual emoji character (e.g., '🔥', '😊') */
|
|
8
|
+
emoji: string;
|
|
9
|
+
/** Array of keywords associated with this emoji for searching */
|
|
10
|
+
keywords: string[];
|
|
11
|
+
/** The category this emoji belongs to (e.g., 'people', 'animals') */
|
|
12
|
+
category: string;
|
|
13
|
+
/** Relevance score (0-1) where 1.0 is exact match, 0.8 is keyword match, 0.6 is alias match */
|
|
14
|
+
score?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Search for emojis by keyword, name, or alias
|
|
18
|
+
*
|
|
19
|
+
* This function uses pre-built indexes for O(1) substring matching performance.
|
|
20
|
+
* Results are scored based on match type:
|
|
21
|
+
* - Name matches: score 1.0
|
|
22
|
+
* - Keyword matches: score 0.8
|
|
23
|
+
* - Alias matches: score 0.6
|
|
24
|
+
*
|
|
25
|
+
* @param keyword - The search term to find emojis for
|
|
26
|
+
* @returns Array of search results sorted by relevance score (highest first)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // Search by name
|
|
31
|
+
* search('fire')
|
|
32
|
+
* // Returns: [{ name: 'fire', emoji: '🔥', score: 1.0, ... }]
|
|
33
|
+
*
|
|
34
|
+
* // Search by keyword
|
|
35
|
+
* search('happy')
|
|
36
|
+
* // Returns: [{ name: 'smile', emoji: '😊', score: 0.8, ... }, ...]
|
|
37
|
+
*
|
|
38
|
+
* // Search by alias
|
|
39
|
+
* search('snapstreak')
|
|
40
|
+
* // Returns: [{ name: 'fire', emoji: '🔥', score: 0.6, ... }]
|
|
41
|
+
*
|
|
42
|
+
* // Partial matches work too
|
|
43
|
+
* search('hap')
|
|
44
|
+
* // Returns emojis with names/keywords/aliases containing 'hap'
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function search(keyword: string): SearchResult[];
|
|
48
|
+
/**
|
|
49
|
+
* Get all emojis that belong to a specific category
|
|
50
|
+
*
|
|
51
|
+
* @param category - The category name to filter by (e.g., 'people', 'animals', 'food')
|
|
52
|
+
* @returns Array of emojis in the specified category, or empty array if category doesn't exist
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Get all animal emojis
|
|
57
|
+
* getByCategory('animals')
|
|
58
|
+
* // Returns: [
|
|
59
|
+
* // { name: 'cat', emoji: '🐈', category: 'animals', ... },
|
|
60
|
+
* // { name: 'dog', emoji: '🐕', category: 'animals', ... },
|
|
61
|
+
* // ...
|
|
62
|
+
* // ]
|
|
63
|
+
*
|
|
64
|
+
* // Invalid category returns empty array
|
|
65
|
+
* getByCategory('invalid')
|
|
66
|
+
* // Returns: []
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function getByCategory(category: string): SearchResult[];
|
|
70
|
+
/**
|
|
71
|
+
* Get a list of all available emoji categories
|
|
72
|
+
*
|
|
73
|
+
* @returns Sorted array of category names
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* getCategories()
|
|
78
|
+
* // Returns: ['animals', 'food', 'nature', 'people', 'travel', ...]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function getCategories(): string[];
|
|
82
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/search/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAA;IAChB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAwED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAiDtD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CAe9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAQxC"}
|