chore: lint related changes and packaging fixes (#6163)
* fix: lint related changes and packaging fixes * adding color validations
This commit is contained in:
parent
b1c340b199
commit
4b5a2bc4e5
71 changed files with 1025 additions and 896 deletions
40
packages/utils/src/emoji.ts
Normal file
40
packages/utils/src/emoji.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* Converts a hyphen-separated hexadecimal emoji code to its decimal representation
|
||||
* @param {string} emojiUnified - The unified emoji code in hexadecimal format (e.g., "1f600" or "1f1e6-1f1e8")
|
||||
* @returns {string} The decimal representation of the emoji code (e.g., "128512" or "127462-127464")
|
||||
* @example
|
||||
* convertHexEmojiToDecimal("1f600") // returns "128512"
|
||||
* convertHexEmojiToDecimal("1f1e6-1f1e8") // returns "127462-127464"
|
||||
* convertHexEmojiToDecimal("") // returns ""
|
||||
*/
|
||||
export const convertHexEmojiToDecimal = (emojiUnified: string): string => {
|
||||
if (!emojiUnified) return "";
|
||||
|
||||
return emojiUnified
|
||||
.toString()
|
||||
.split("-")
|
||||
.map((e) => parseInt(e, 16))
|
||||
.join("-");
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a hyphen-separated decimal emoji code back to its hexadecimal representation
|
||||
* @param {string} emoji - The emoji code in decimal format (e.g., "128512" or "127462-127464")
|
||||
* @returns {string} The hexadecimal representation of the emoji code (e.g., "1f600" or "1f1e6-1f1e8")
|
||||
* @example
|
||||
* emojiCodeToUnicode("128512") // returns "1f600"
|
||||
* emojiCodeToUnicode("127462-127464") // returns "1f1e6-1f1e8"
|
||||
* emojiCodeToUnicode("") // returns ""
|
||||
*/
|
||||
export const emojiCodeToUnicode = (emoji: string): string => {
|
||||
if (!emoji) return "";
|
||||
|
||||
// convert emoji code to unicode
|
||||
const uniCodeEmoji = emoji
|
||||
.toString()
|
||||
.split("-")
|
||||
.map((emoji) => parseInt(emoji, 10).toString(16))
|
||||
.join("-");
|
||||
|
||||
return uniCodeEmoji;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue