Comparing version 1.0.1 to 1.0.2
13
index.js
@@ -15,7 +15,5 @@ 'use strict' | ||
const chance = Math.random() < (opts.probability / 100) | ||
return replace(text, dict, chance) | ||
return replace(text, dict, () => Math.random() < (opts.probability / 100)) | ||
} | ||
function splice (str, index, count, add) { | ||
@@ -28,7 +26,14 @@ return str.slice(0, index) + add + str.slice(index + count) | ||
let pos = 0 | ||
for (let char of original) { | ||
const replacement = dict.get(char) | ||
if (replacement !== undefined) { | ||
const fakeLetter = Array.isArray(replacement) ? replacement[Math.floor(Math.random() * replacement.length)] : replacement | ||
if (condition) text = splice(text, pos, 1, fakeLetter) | ||
if (typeof condition === 'function') { | ||
if (condition()) text = splice(text, pos, 1, fakeLetter) | ||
} else { | ||
text = splice(text, pos, 1, fakeLetter) | ||
} | ||
} | ||
@@ -35,0 +40,0 @@ |
{ | ||
"name": "homoglyph", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Replace ascii chars with their same looking utf8 chars.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
7775
152
0