New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emojify-lyrics

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emojify-lyrics - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

3

dist/emojify.d.ts

@@ -7,3 +7,4 @@ export interface EmojifyOptions {

multimojiChance?: number;
allowFlags?: boolean;
}
export declare function emojify(inputText: string, { replace, replaceChance, tripleCooldown, tripleChance, multimojiChance, }?: EmojifyOptions): string;
export declare function emojify(inputText: string, { replace, replaceChance, tripleCooldown, tripleChance, multimojiChance, allowFlags, }?: EmojifyOptions): string;
import emojiMapJson from './emojiMap.json';
const emojiMap = emojiMapJson;
export function emojify(inputText, { replace = false, replaceChance = 1, tripleCooldown = 3, tripleChance = 0.05, multimojiChance = 0.1, } = {}) {
export function emojify(inputText, { replace = false, replaceChance = 1, tripleCooldown = 3, tripleChance = 0.05, multimojiChance = 0.1, allowFlags = true, } = {}) {
const lines = inputText.split(/\n/);

@@ -18,2 +18,5 @@ const outputLines = [];

if (emojis.length > 0) {
if (!allowFlags) {
stripFlags(emojis);
}
const grabEmoji = () => {

@@ -160,5 +163,22 @@ const emojiIndex = Math.floor(Math.random() * emojis.length);

}
/**
* In-place removal of flag emojis from the list.
*
* @param emojis The list of emojis to strip flags from.
*/
function stripFlags(emojis) {
for (let i = emojis.length - 1; i >= 0; i--) {
if (isFlagEmoji(emojis[i])) {
emojis.splice(i, 1);
}
}
}
// https://stackoverflow.com/questions/53360006/detect-with-regex-if-emoji-is-country-flag
const flagMatcher = /[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/;
function isFlagEmoji(emoji) {
return emoji.length === 4 && emoji.match(flagMatcher) !== null;
}
// Adopted from https://github.com/notwaldorf/emoji-translate/blob/master/emoji-translate.js for dependency reasons
// MIT License, available at https://raw.githubusercontent.com/notwaldorf/emoji-translate/master/LICENSE
const rangeMatcher = [
const rangeMatcherString = [
'\uD83C[\uDF00-\uDFFF]', // U+1F300 to U+1F3FF

@@ -168,2 +188,3 @@ '\uD83D[\uDC00-\uDE4F]', // U+1F400 to U+1F64F

].join('|');
const rangeMatcher = new RegExp(rangeMatcherString);
/**

@@ -170,0 +191,0 @@ * Returns true for something that's already an emoji like 🤖.

{
"name": "emojify-lyrics",
"version": "2.3.0",
"version": "2.4.0",
"description": "Making the world a :slight_smile: place",

@@ -35,7 +35,7 @@ "module": "dist/index.js",

"husky": "^9.1.7",
"lint-staged": "^15.2.11",
"lint-staged": "^15.3.0",
"pinst": "^3.0.0",
"prettier": "^3.4.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0",
"typescript-eslint": "^8.19.0",
"unicode-emoji-json": "^0.8.0",

@@ -42,0 +42,0 @@ "vitest": "^2.1.8"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc