Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pseudo-localization

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pseudo-localization - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

34

index.js

@@ -67,18 +67,16 @@ const pseudoLocalization = (() => {

const textNodesUnder = element => {
let n;
const a = [];
const walk = document.createTreeWalker(
const walker = document.createTreeWalker(
element,
NodeFilter.SHOW_TEXT,
node => {
const isAllWs = !/[^\s]/.test(node.nodeValue);
// A comment node or a text node, all whitespace
const isIgnorable =
node.nodeType == 8 || (node.nodeType == 3 && isAllWs);
if (isIgnorable) return NodeFilter.FILTER_REJECT;
const isAllWhitespace = !/[^\s]/.test(node.nodeValue);
if (isAllWhitespace) return NodeFilter.FILTER_REJECT;
return NodeFilter.FILTER_ACCEPT;
}
);
while ((n = walk.nextNode())) a.push(n);
return a;
let currNode;
const textNodes = [];
while ((currNode = walker.nextNode())) textNodes.push(currNode);
return textNodes;
};

@@ -88,13 +86,14 @@

let pseudoLocalizedText = "";
for (let c of string) {
if (map[c]) {
for (let character of string) {
if (map[character]) {
pseudoLocalizedText +=
map[c][Math.floor(Math.random() * map[c].length)];
} else pseudoLocalizedText += c;
map[character][Math.floor(Math.random() * map[character].length)];
} else pseudoLocalizedText += character;
}
const explodeRatio = 1.4;
const explodedTextLength = Math.ceil(string.length * explodeRatio);
// Trim strings to prevent whitespace from increasing the explosion amount
const explodedTextLength = Math.ceil(string.trim().length * explodeRatio);
let i = 0;
while (pseudoLocalizedText.length < explodedTextLength) {
while (pseudoLocalizedText.trim().length < explodedTextLength) {
pseudoLocalizedText += " " + explosionSymbols[i++];

@@ -114,3 +113,2 @@ }

const domMutationCallback = mutationsList => {
console.log(mutationsList);
for (var mutation of mutationsList) {

@@ -137,3 +135,3 @@ if (mutation.type === "childList" && mutation.addedNodes.length > 0) {

}
}
};

@@ -140,0 +138,0 @@ // Observe dom update and pseudo localize changed nodes.

{
"name": "pseudo-localization",
"version": "1.1.1",
"version": "1.1.2",
"description": "Dynamic pseudo-localization in the browser",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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