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.
Files changed (79) hide show
  1. package/README.md +201 -123
  2. package/lib/backward-compat.d.ts +29 -0
  3. package/lib/backward-compat.d.ts.map +1 -0
  4. package/lib/backward-compat.js +160 -0
  5. package/lib/backward-compat.js.map +1 -0
  6. package/lib/categories/animals.d.ts +3 -0
  7. package/lib/categories/animals.d.ts.map +1 -0
  8. package/lib/categories/animals.js +17 -0
  9. package/lib/categories/animals.js.map +1 -0
  10. package/lib/categories/food.d.ts +3 -0
  11. package/lib/categories/food.d.ts.map +1 -0
  12. package/lib/categories/food.js +17 -0
  13. package/lib/categories/food.js.map +1 -0
  14. package/lib/categories/nature.d.ts +3 -0
  15. package/lib/categories/nature.d.ts.map +1 -0
  16. package/lib/categories/nature.js +17 -0
  17. package/lib/categories/nature.js.map +1 -0
  18. package/lib/categories/people.d.ts +3 -0
  19. package/lib/categories/people.d.ts.map +1 -0
  20. package/lib/categories/people.js +17 -0
  21. package/lib/categories/people.js.map +1 -0
  22. package/lib/categories/travel.d.ts +3 -0
  23. package/lib/categories/travel.d.ts.map +1 -0
  24. package/lib/categories/travel.js +17 -0
  25. package/lib/categories/travel.js.map +1 -0
  26. package/lib/core/emoji.d.ts +46 -0
  27. package/lib/core/emoji.d.ts.map +1 -0
  28. package/lib/core/emoji.js +3 -0
  29. package/lib/core/emoji.js.map +1 -0
  30. package/lib/data/aliases.json +472 -0
  31. package/lib/data/categories.json +381 -0
  32. package/lib/data/emojis.json +371 -0
  33. package/lib/data/metadata.json +3254 -0
  34. package/lib/data/skin-tones.json +196 -0
  35. package/lib/features/aliases/index.d.ts +375 -0
  36. package/lib/features/aliases/index.d.ts.map +1 -0
  37. package/lib/features/aliases/index.js +230 -0
  38. package/lib/features/aliases/index.js.map +1 -0
  39. package/lib/features/filters/index.d.ts +119 -0
  40. package/lib/features/filters/index.d.ts.map +1 -0
  41. package/lib/features/filters/index.js +196 -0
  42. package/lib/features/filters/index.js.map +1 -0
  43. package/lib/features/search/index.d.ts +82 -0
  44. package/lib/features/search/index.d.ts.map +1 -0
  45. package/lib/features/search/index.js +204 -0
  46. package/lib/features/search/index.js.map +1 -0
  47. package/lib/features/skin-tones/index.d.ts +119 -0
  48. package/lib/features/skin-tones/index.d.ts.map +1 -0
  49. package/lib/features/skin-tones/index.js +184 -0
  50. package/lib/features/skin-tones/index.js.map +1 -0
  51. package/lib/index.d.ts +29 -0
  52. package/lib/index.d.ts.map +1 -0
  53. package/lib/index.js +57 -3
  54. package/lib/index.js.map +1 -0
  55. package/lib/types/index.d.ts +21 -0
  56. package/lib/types/index.d.ts.map +1 -0
  57. package/lib/types/index.js +3 -0
  58. package/lib/types/index.js.map +1 -0
  59. package/lib/utils/reverse-mapping.d.ts +111 -0
  60. package/lib/utils/reverse-mapping.d.ts.map +1 -0
  61. package/lib/utils/reverse-mapping.js +138 -0
  62. package/lib/utils/reverse-mapping.js.map +1 -0
  63. package/lib/utils/validators.d.ts +63 -0
  64. package/lib/utils/validators.d.ts.map +1 -0
  65. package/lib/utils/validators.js +106 -0
  66. package/lib/utils/validators.js.map +1 -0
  67. package/package.json +121 -17
  68. package/.github/FUNDING.yml +0 -5
  69. package/.github/workflows/nodejs.yml +0 -26
  70. package/.travis.yml +0 -12
  71. package/CODE_OF_CONDUCT.md +0 -46
  72. package/lib/emojis/animal-emojis.js +0 -71
  73. package/lib/emojis/emojis.js +0 -9
  74. package/lib/emojis/food-emojis.js +0 -42
  75. package/lib/emojis/index.js +0 -3
  76. package/lib/emojis/nature-emojis.js +0 -9
  77. package/lib/emojis/people-emojis.js +0 -181
  78. package/lib/emojis/travel-emojis.js +0 -17
  79. package/test/test.js +0 -26
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Get emoji name from its character
3
+ *
4
+ * Performs a reverse lookup to find the canonical name of an emoji
5
+ * given its character representation.
6
+ *
7
+ * @param emoji - The emoji character to look up
8
+ * @returns The canonical name if found, undefined otherwise
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Find name from emoji
13
+ * getNameFromEmoji('🔥')
14
+ * // Returns: 'fire'
15
+ *
16
+ * // Unknown emoji returns undefined
17
+ * getNameFromEmoji('🌀')
18
+ * // Returns: undefined
19
+ *
20
+ * // Works with multi-character emojis
21
+ * getNameFromEmoji('👨‍👩‍👧')
22
+ * // Returns: 'family_man_woman_girl'
23
+ * ```
24
+ */
25
+ export declare function getNameFromEmoji(emoji: string): string | undefined;
26
+ /**
27
+ * Get the complete reverse mapping
28
+ *
29
+ * Returns a frozen copy of the reverse emoji mapping (emoji → name).
30
+ * Useful for bulk operations or building custom lookup tables.
31
+ *
32
+ * @returns Read-only object mapping emoji characters to their names
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const reverseMap = getReverseMapping()
37
+ * // Returns: {
38
+ * // '🔥': 'fire',
39
+ * // '😊': 'smile',
40
+ * // '👍': 'thumbsup',
41
+ * // // ... all other emojis
42
+ * // }
43
+ *
44
+ * // Use for lookups (read-only)
45
+ * reverseMap['🔥'] // 'fire'
46
+ *
47
+ * // Attempting to modify throws error
48
+ * reverseMap['🔥'] = 'flame' // TypeError: Cannot assign to read only property
49
+ * ```
50
+ */
51
+ export declare function getReverseMapping(): Readonly<Record<string, string>>;
52
+ /**
53
+ * Check if a string is a valid emoji in the database
54
+ *
55
+ * Verifies whether a given string is a recognized emoji character
56
+ * in the node-emojis database.
57
+ *
58
+ * @param str - The string to check
59
+ * @returns true if the string is a known emoji, false otherwise
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Known emoji
64
+ * isKnownEmoji('🔥')
65
+ * // Returns: true
66
+ *
67
+ * // Unknown emoji
68
+ * isKnownEmoji('🌀')
69
+ * // Returns: false
70
+ *
71
+ * // Not an emoji
72
+ * isKnownEmoji('hello')
73
+ * // Returns: false
74
+ *
75
+ * // Works with complex emojis
76
+ * isKnownEmoji('👨‍👩‍👧')
77
+ * // Returns: true (if family emoji is in database)
78
+ * ```
79
+ */
80
+ export declare function isKnownEmoji(str: string): boolean;
81
+ /**
82
+ * Create a reverse mapping from any emoji object
83
+ *
84
+ * Utility function to create a reverse lookup table from any
85
+ * name→emoji mapping. Useful for working with custom emoji sets.
86
+ *
87
+ * @param emojiObject - Object mapping names to emoji characters
88
+ * @returns New object mapping emoji characters to names
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Create reverse mapping from custom set
93
+ * const customEmojis = {
94
+ * happy: '😊',
95
+ * sad: '😢',
96
+ * fire: '🔥'
97
+ * }
98
+ *
99
+ * const reverseCustom = createReverseMapping(customEmojis)
100
+ * // Returns: {
101
+ * // '😊': 'happy',
102
+ * // '😢': 'sad',
103
+ * // '🔥': 'fire'
104
+ * // }
105
+ *
106
+ * // Use for lookups
107
+ * reverseCustom['🔥'] // 'fire'
108
+ * ```
109
+ */
110
+ export declare function createReverseMapping(emojiObject: Record<string, string>): Record<string, string>;
111
+ //# sourceMappingURL=reverse-mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-mapping.d.ts","sourceRoot":"","sources":["../../src/utils/reverse-mapping.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEpE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMhG"}
@@ -0,0 +1,138 @@
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.getNameFromEmoji = getNameFromEmoji;
7
+ exports.getReverseMapping = getReverseMapping;
8
+ exports.isKnownEmoji = isKnownEmoji;
9
+ exports.createReverseMapping = createReverseMapping;
10
+ const emojis_json_1 = __importDefault(require("../data/emojis.json"));
11
+ // Create reverse mapping on module load
12
+ const reverseMap = {};
13
+ Object.entries(emojis_json_1.default).forEach(([name, emoji]) => {
14
+ reverseMap[emoji] = name;
15
+ });
16
+ /**
17
+ * Get emoji name from its character
18
+ *
19
+ * Performs a reverse lookup to find the canonical name of an emoji
20
+ * given its character representation.
21
+ *
22
+ * @param emoji - The emoji character to look up
23
+ * @returns The canonical name if found, undefined otherwise
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Find name from emoji
28
+ * getNameFromEmoji('🔥')
29
+ * // Returns: 'fire'
30
+ *
31
+ * // Unknown emoji returns undefined
32
+ * getNameFromEmoji('🌀')
33
+ * // Returns: undefined
34
+ *
35
+ * // Works with multi-character emojis
36
+ * getNameFromEmoji('👨‍👩‍👧')
37
+ * // Returns: 'family_man_woman_girl'
38
+ * ```
39
+ */
40
+ function getNameFromEmoji(emoji) {
41
+ return reverseMap[emoji];
42
+ }
43
+ /**
44
+ * Get the complete reverse mapping
45
+ *
46
+ * Returns a frozen copy of the reverse emoji mapping (emoji → name).
47
+ * Useful for bulk operations or building custom lookup tables.
48
+ *
49
+ * @returns Read-only object mapping emoji characters to their names
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const reverseMap = getReverseMapping()
54
+ * // Returns: {
55
+ * // '🔥': 'fire',
56
+ * // '😊': 'smile',
57
+ * // '👍': 'thumbsup',
58
+ * // // ... all other emojis
59
+ * // }
60
+ *
61
+ * // Use for lookups (read-only)
62
+ * reverseMap['🔥'] // 'fire'
63
+ *
64
+ * // Attempting to modify throws error
65
+ * reverseMap['🔥'] = 'flame' // TypeError: Cannot assign to read only property
66
+ * ```
67
+ */
68
+ function getReverseMapping() {
69
+ return Object.freeze({ ...reverseMap });
70
+ }
71
+ /**
72
+ * Check if a string is a valid emoji in the database
73
+ *
74
+ * Verifies whether a given string is a recognized emoji character
75
+ * in the node-emojis database.
76
+ *
77
+ * @param str - The string to check
78
+ * @returns true if the string is a known emoji, false otherwise
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // Known emoji
83
+ * isKnownEmoji('🔥')
84
+ * // Returns: true
85
+ *
86
+ * // Unknown emoji
87
+ * isKnownEmoji('🌀')
88
+ * // Returns: false
89
+ *
90
+ * // Not an emoji
91
+ * isKnownEmoji('hello')
92
+ * // Returns: false
93
+ *
94
+ * // Works with complex emojis
95
+ * isKnownEmoji('👨‍👩‍👧')
96
+ * // Returns: true (if family emoji is in database)
97
+ * ```
98
+ */
99
+ function isKnownEmoji(str) {
100
+ return str in reverseMap;
101
+ }
102
+ /**
103
+ * Create a reverse mapping from any emoji object
104
+ *
105
+ * Utility function to create a reverse lookup table from any
106
+ * name→emoji mapping. Useful for working with custom emoji sets.
107
+ *
108
+ * @param emojiObject - Object mapping names to emoji characters
109
+ * @returns New object mapping emoji characters to names
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * // Create reverse mapping from custom set
114
+ * const customEmojis = {
115
+ * happy: '😊',
116
+ * sad: '😢',
117
+ * fire: '🔥'
118
+ * }
119
+ *
120
+ * const reverseCustom = createReverseMapping(customEmojis)
121
+ * // Returns: {
122
+ * // '😊': 'happy',
123
+ * // '😢': 'sad',
124
+ * // '🔥': 'fire'
125
+ * // }
126
+ *
127
+ * // Use for lookups
128
+ * reverseCustom['🔥'] // 'fire'
129
+ * ```
130
+ */
131
+ function createReverseMapping(emojiObject) {
132
+ const reverse = {};
133
+ Object.entries(emojiObject).forEach(([name, emoji]) => {
134
+ reverse[emoji] = name;
135
+ });
136
+ return reverse;
137
+ }
138
+ //# sourceMappingURL=reverse-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reverse-mapping.js","sourceRoot":"","sources":["../../src/utils/reverse-mapping.ts"],"names":[],"mappings":";;;;;AAiCA,4CAEC;AA2BD,8CAEC;AA8BD,oCAEC;AA+BD,oDAMC;AArID,sEAAwC;AAExC,wCAAwC;AACxC,MAAM,UAAU,GAA2B,EAAE,CAAA;AAE7C,MAAM,CAAC,OAAO,CAAC,qBAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;IAC/C,UAAU,CAAC,KAAe,CAAC,GAAG,IAAI,CAAA;AACpC,CAAC,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,OAAO,UAAU,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,IAAI,UAAU,CAAA;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,oBAAoB,CAAC,WAAmC;IACtE,MAAM,OAAO,GAA2B,EAAE,CAAA;IAC1C,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACpD,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IACvB,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { SkinTone, SkinToneAlias } from '../features/skin-tones';
2
+ /**
3
+ * Check if a string is a valid emoji character
4
+ *
5
+ * This function uses a two-step validation approach:
6
+ * 1. First checks against the known emoji database for exact matches (O(1) lookup)
7
+ * 2. Falls back to regex validation for emojis that might not be in our database
8
+ *
9
+ * The regex pattern covers Unicode ranges for:
10
+ * - Emoticons (U+1F600-U+1F64F)
11
+ * - Miscellaneous Symbols and Pictographs (U+1F300-U+1F5FF)
12
+ * - Transport and Map Symbols (U+1F680-U+1F6FF)
13
+ * - Supplemental Symbols and Pictographs (U+1F900-U+1F9FF, U+1FA00-U+1FAFF)
14
+ * - Flags (U+1F1E6-U+1F1FF)
15
+ * - Skin tone modifiers (U+1F3FB-U+1F3FF)
16
+ * - Zero-width joiner (U+200D) and variation selector (U+FE0F)
17
+ *
18
+ * Limitations:
19
+ * - May not recognize very new emojis not yet in the database
20
+ * - Complex emoji sequences with multiple components might not be fully validated
21
+ *
22
+ * Note: This function will return true for strings containing only emoji characters,
23
+ * including multiple emojis like '😀😀' or '🔥💧'. This is intentional as the function
24
+ * validates whether the string consists entirely of emoji codepoints.
25
+ *
26
+ * @param str - The string to validate
27
+ * @returns true if the string consists only of emoji characters, false otherwise
28
+ */
29
+ export declare function isValidEmoji(str: string): boolean;
30
+ /**
31
+ * Check if a string is a valid emoji name
32
+ */
33
+ export declare function isValidEmojiName(name: string): boolean;
34
+ /**
35
+ * Check if a string is a valid skin tone
36
+ */
37
+ export declare function isValidSkinTone(tone: string): tone is SkinTone | SkinToneAlias;
38
+ /**
39
+ * Validate and sanitize emoji name
40
+ */
41
+ export declare function sanitizeEmojiName(name: string): string;
42
+ /**
43
+ * Check if a string contains variation selector
44
+ *
45
+ * Variation selectors (U+FE0F) are used to request an emoji presentation
46
+ * of characters that have both text and emoji representations.
47
+ *
48
+ * @param str - The string to check for variation selectors
49
+ * @returns true if the string contains at least one variation selector, false otherwise
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * hasVariationSelector('❤️') // true (heart with emoji presentation)
54
+ * hasVariationSelector('❤') // false (heart without variation selector)
55
+ * hasVariationSelector('') // false (empty string)
56
+ * ```
57
+ */
58
+ export declare function hasVariationSelector(str: string): boolean;
59
+ /**
60
+ * Strip variation selectors from string
61
+ */
62
+ export declare function stripVariationSelectors(str: string): string;
63
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAKhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAkBjD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMtD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,QAAQ,GAAG,aAAa,CAG9E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3D"}
@@ -0,0 +1,106 @@
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.isValidEmoji = isValidEmoji;
7
+ exports.isValidEmojiName = isValidEmojiName;
8
+ exports.isValidSkinTone = isValidSkinTone;
9
+ exports.sanitizeEmojiName = sanitizeEmojiName;
10
+ exports.hasVariationSelector = hasVariationSelector;
11
+ exports.stripVariationSelectors = stripVariationSelectors;
12
+ const emojis_json_1 = __importDefault(require("../data/emojis.json"));
13
+ // Create a Set for O(1) emoji lookups
14
+ const validEmojisSet = new Set(Object.values(emojis_json_1.default));
15
+ /**
16
+ * Check if a string is a valid emoji character
17
+ *
18
+ * This function uses a two-step validation approach:
19
+ * 1. First checks against the known emoji database for exact matches (O(1) lookup)
20
+ * 2. Falls back to regex validation for emojis that might not be in our database
21
+ *
22
+ * The regex pattern covers Unicode ranges for:
23
+ * - Emoticons (U+1F600-U+1F64F)
24
+ * - Miscellaneous Symbols and Pictographs (U+1F300-U+1F5FF)
25
+ * - Transport and Map Symbols (U+1F680-U+1F6FF)
26
+ * - Supplemental Symbols and Pictographs (U+1F900-U+1F9FF, U+1FA00-U+1FAFF)
27
+ * - Flags (U+1F1E6-U+1F1FF)
28
+ * - Skin tone modifiers (U+1F3FB-U+1F3FF)
29
+ * - Zero-width joiner (U+200D) and variation selector (U+FE0F)
30
+ *
31
+ * Limitations:
32
+ * - May not recognize very new emojis not yet in the database
33
+ * - Complex emoji sequences with multiple components might not be fully validated
34
+ *
35
+ * Note: This function will return true for strings containing only emoji characters,
36
+ * including multiple emojis like '😀😀' or '🔥💧'. This is intentional as the function
37
+ * validates whether the string consists entirely of emoji codepoints.
38
+ *
39
+ * @param str - The string to validate
40
+ * @returns true if the string consists only of emoji characters, false otherwise
41
+ */
42
+ function isValidEmoji(str) {
43
+ if (!str)
44
+ return false;
45
+ // Check against known emojis first (most reliable) - O(1) lookup
46
+ if (validEmojisSet.has(str)) {
47
+ return true;
48
+ }
49
+ // Additional check for common text characters to quickly reject mixed content
50
+ if (/[a-zA-Z0-9\s]/.test(str)) {
51
+ return false;
52
+ }
53
+ // Use a character class approach without quantifiers to avoid ReDoS
54
+ // This checks if the string consists only of emoji-related characters
55
+ const emojiChars = /^[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{1F1E6}-\u{1F1FF}\u{1F3FB}-\u{1F3FF}\u{200D}\u{FE0F}]+$/u;
56
+ return emojiChars.test(str);
57
+ }
58
+ /**
59
+ * Check if a string is a valid emoji name
60
+ */
61
+ function isValidEmojiName(name) {
62
+ if (!name)
63
+ return false;
64
+ // Valid emoji names contain only letters, numbers, underscores, and hyphens
65
+ const validNameRegex = /^[a-zA-Z0-9_-]+$/;
66
+ return validNameRegex.test(name);
67
+ }
68
+ /**
69
+ * Check if a string is a valid skin tone
70
+ */
71
+ function isValidSkinTone(tone) {
72
+ const validTones = ['light', 'medium-light', 'medium', 'medium-dark', 'dark', '1', '2', '3', '4', '5'];
73
+ return validTones.includes(tone);
74
+ }
75
+ /**
76
+ * Validate and sanitize emoji name
77
+ */
78
+ function sanitizeEmojiName(name) {
79
+ return name.replace(/[^a-zA-Z0-9_-]/g, '_');
80
+ }
81
+ /**
82
+ * Check if a string contains variation selector
83
+ *
84
+ * Variation selectors (U+FE0F) are used to request an emoji presentation
85
+ * of characters that have both text and emoji representations.
86
+ *
87
+ * @param str - The string to check for variation selectors
88
+ * @returns true if the string contains at least one variation selector, false otherwise
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * hasVariationSelector('❤️') // true (heart with emoji presentation)
93
+ * hasVariationSelector('❤') // false (heart without variation selector)
94
+ * hasVariationSelector('') // false (empty string)
95
+ * ```
96
+ */
97
+ function hasVariationSelector(str) {
98
+ return str.includes('\u{FE0F}');
99
+ }
100
+ /**
101
+ * Strip variation selectors from string
102
+ */
103
+ function stripVariationSelectors(str) {
104
+ return str.replace(/\u{FE0F}/gu, '');
105
+ }
106
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":";;;;;AAiCA,oCAkBC;AAKD,4CAMC;AAKD,0CAGC;AAKD,8CAEC;AAkBD,oDAEC;AAKD,0DAEC;AAxGD,sEAAwC;AAGxC,sCAAsC;AACtC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAM,CAAC,CAAC,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IAEtB,iEAAiE;IACjE,IAAI,cAAc,CAAC,GAAG,CAAC,GAAU,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,8EAA8E;IAC9E,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,oEAAoE;IACpE,sEAAsE;IACtE,MAAM,UAAU,GAAG,2QAA2Q,CAAA;IAE9R,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IAEvB,4EAA4E;IAC5E,MAAM,cAAc,GAAG,kBAAkB,CAAA;IACzC,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACtG,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,GAAW;IACjD,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,24 +1,110 @@
1
1
  {
2
2
  "name": "node-emojis",
3
- "version": "0.0.4",
4
- "description": "Emojis that you can use in your application 😊",
3
+ "version": "1.0.0",
4
+ "description": "Modern, tree-shakeable emoji library for Node.js with TypeScript, search, skin tones, and aliases 🎉",
5
5
  "main": "lib/index.js",
6
+ "module": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "sideEffects": false,
6
9
  "scripts": {
7
- "cover": "node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha -- -R spec test/*",
8
- "lint": "standard",
9
- "lint:fix": "standard --fix",
10
- "test": "npm run cover"
10
+ "build": "tsc",
11
+ "clean": "rm -rf dist lib",
12
+ "prebuild": "npm run clean",
13
+ "prepublishOnly": "npm run build && npm test",
14
+ "cover": "cross-env TS_NODE_PROJECT=tsconfig.test.json nyc mocha",
15
+ "cover:ci": "npm run cover",
16
+ "lint": "npm run lint:ts && npm run lint:md && npm run lint:yaml",
17
+ "lint:ts": "tsc --noEmit --project tsconfig.test.json",
18
+ "lint:ts:fix": "echo 'TypeScript linting complete'",
19
+ "lint:md": "markdownlint-cli2 \"**/*.md\" \"#node_modules\"",
20
+ "lint:md:fix": "markdownlint-cli2 --fix \"**/*.md\" \"#node_modules\"",
21
+ "lint:yaml": "yamllint .github/**/*.yml *.yml *.yaml --ignore=node_modules",
22
+ "lint:fix": "npm run lint:ts:fix && npm run lint:md:fix",
23
+ "test": "npm run cover",
24
+ "prepare": "husky",
25
+ "lint:check-bypass": "node scripts/check-bypass.js"
11
26
  },
12
27
  "repository": "git+https://github.com/jesselpalmer/node-emojis.git",
13
28
  "engines": {
14
- "node": ">=4.2.4"
29
+ "node": ">=20.0.0"
15
30
  },
16
- "pre-commit": [
17
- "lint",
18
- "test"
31
+ "files": [
32
+ "lib/"
19
33
  ],
34
+ "exports": {
35
+ ".": {
36
+ "types": "./lib/index.d.ts",
37
+ "require": "./lib/index.js",
38
+ "import": "./lib/index.js"
39
+ },
40
+ "./search": {
41
+ "types": "./lib/features/search/index.d.ts",
42
+ "require": "./lib/features/search/index.js",
43
+ "import": "./lib/features/search/index.js"
44
+ },
45
+ "./skin-tones": {
46
+ "types": "./lib/features/skin-tones/index.d.ts",
47
+ "require": "./lib/features/skin-tones/index.js",
48
+ "import": "./lib/features/skin-tones/index.js"
49
+ },
50
+ "./aliases": {
51
+ "types": "./lib/features/aliases/index.d.ts",
52
+ "require": "./lib/features/aliases/index.js",
53
+ "import": "./lib/features/aliases/index.js"
54
+ },
55
+ "./filters": {
56
+ "types": "./lib/features/filters/index.d.ts",
57
+ "require": "./lib/features/filters/index.js",
58
+ "import": "./lib/features/filters/index.js"
59
+ },
60
+ "./animals": {
61
+ "types": "./lib/categories/animals.d.ts",
62
+ "require": "./lib/categories/animals.js",
63
+ "import": "./lib/categories/animals.js"
64
+ },
65
+ "./food": {
66
+ "types": "./lib/categories/food.d.ts",
67
+ "require": "./lib/categories/food.js",
68
+ "import": "./lib/categories/food.js"
69
+ },
70
+ "./nature": {
71
+ "types": "./lib/categories/nature.d.ts",
72
+ "require": "./lib/categories/nature.js",
73
+ "import": "./lib/categories/nature.js"
74
+ },
75
+ "./people": {
76
+ "types": "./lib/categories/people.d.ts",
77
+ "require": "./lib/categories/people.js",
78
+ "import": "./lib/categories/people.js"
79
+ },
80
+ "./travel": {
81
+ "types": "./lib/categories/travel.d.ts",
82
+ "require": "./lib/categories/travel.js",
83
+ "import": "./lib/categories/travel.js"
84
+ },
85
+ "./package.json": "./package.json"
86
+ },
20
87
  "keywords": [
21
- "emojis"
88
+ "emoji",
89
+ "emojis",
90
+ "unicode",
91
+ "emoticons",
92
+ "smileys",
93
+ "typescript",
94
+ "skin-tone",
95
+ "aliases",
96
+ "search",
97
+ "tree-shaking",
98
+ "es-modules",
99
+ "commonjs",
100
+ "emoji-search",
101
+ "emoji-picker",
102
+ "unicode-emojis",
103
+ "emoji-aliases",
104
+ "emoji-library",
105
+ "nodejs",
106
+ "javascript",
107
+ "zero-dependencies"
22
108
  ],
23
109
  "author": "Jesse Palmer <jesselpalmer@gmail.com> (http://jesselpalmer.com/)",
24
110
  "license": "MIT",
@@ -27,11 +113,29 @@
27
113
  },
28
114
  "homepage": "https://github.com/jesselpalmer/node-emojis#readme",
29
115
  "devDependencies": {
30
- "chai": "4.2.0",
31
- "coveralls": "3.0.6",
32
- "istanbul": "0.4.5",
33
- "mocha": "6.2.0",
34
- "pre-commit": "1.2.2",
35
- "standard": "13.1.0"
116
+ "@commitlint/cli": "^19.8.1",
117
+ "@commitlint/config-conventional": "^19.8.1",
118
+ "@istanbuljs/nyc-config-typescript": "^1.0.2",
119
+ "@types/chai": "^5.2.2",
120
+ "@types/mocha": "^10.0.10",
121
+ "@types/node": "^24.0.10",
122
+ "chai": "^5.2.0",
123
+ "cross-env": "^7.0.3",
124
+ "husky": "^9.1.7",
125
+ "markdownlint-cli2": "^0.18.1",
126
+ "mocha": "^11.7.1",
127
+ "nyc": "^17.1.0",
128
+ "ts-node": "^10.9.2",
129
+ "tslib": "^2.8.1",
130
+ "typescript": "^5.8.3",
131
+ "yaml-lint": "^1.7.0"
132
+ },
133
+ "nyc": {
134
+ "extends": "@istanbuljs/nyc-config-typescript",
135
+ "check-coverage": true,
136
+ "lines": 85,
137
+ "statements": 85,
138
+ "functions": 75,
139
+ "branches": 60
36
140
  }
37
141
  }
@@ -1,5 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: jesselpalmer
4
- patreon: jesselpalmer
5
- ko_fi: jesselpalmer
@@ -1,26 +0,0 @@
1
- name: Node CI
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
-
10
- strategy:
11
- matrix:
12
- node-version: [8.x, 10.x, 12.x]
13
-
14
- steps:
15
- - uses: actions/checkout@v1
16
- - name: Use Node.js ${{ matrix.node-version }}
17
- uses: actions/setup-node@v1
18
- with:
19
- node-version: ${{ matrix.node-version }}
20
- - name: npm install, build, and test
21
- run: |
22
- npm install
23
- npm run build --if-present
24
- npm test
25
- env:
26
- CI: true
package/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: node_js
2
-
3
- node_js:
4
- - stable
5
-
6
- install:
7
- - npm install
8
-
9
- script:
10
- - npm test
11
-
12
- after_script: "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js"