@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
30 lines • 1.05 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = isEmoji;
/**
* Checks whether a given string contains an emoji.
*
* @param str - The string to check for emojis.
* @returns A boolean indicating whether the string contains an emoji.
*
* @example
* isEmoji("😊"); // Output: true
* isEmoji("hello"); // Output: false
* isEmoji("👋 hello!"); // Output: true
*/
function isEmoji(str) {
// Emoji regex pattern (matches most emojis)
const emojiRegex = /[\p{Emoji}\u200d\u20e3\u25aa\u2b06\ufe0f]/gu;
return emojiRegex.test(str);
}
});
//# sourceMappingURL=isEmoji.js.map