Socket
Socket
Sign inDemoInstall

@domql/utils

Package Overview
Dependencies
Maintainers
1
Versions
168
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@domql/utils - npm Package Compare versions

Comparing version 2.5.95 to 2.5.97

13

array.js

@@ -133,1 +133,14 @@ 'use strict'

}
export const arraysEqual = (arr1, arr2) => {
if (arr1.length !== arr2.length) {
return false
}
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
return false
}
}
return true
}

@@ -23,2 +23,3 @@ "use strict";

arrayContainsOtherArray: () => arrayContainsOtherArray,
arraysEqual: () => arraysEqual,
createNestedObject: () => createNestedObject,

@@ -140,1 +141,12 @@ cutArrayAfterValue: () => cutArrayAfterValue,

};
const arraysEqual = (arr1, arr2) => {
if (arr1.length !== arr2.length) {
return false;
}
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
return false;
}
}
return true;
};

@@ -21,4 +21,6 @@ "use strict";

__export(string_exports, {
findKeyPosition: () => findKeyPosition,
lowercaseFirstLetter: () => lowercaseFirstLetter,
replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
replaceOctalEscapeSequences: () => replaceOctalEscapeSequences,
stringIncludesAny: () => stringIncludesAny,

@@ -69,1 +71,55 @@ trimStringFromSymbols: () => trimStringFromSymbols

};
const findKeyPosition = (str, key) => {
const lines = str.split("\n");
let startLineNumber = -1;
let endLineNumber = -1;
let startColumn = -1;
let endColumn = -1;
const keyPattern = new RegExp(`\\b${key}\\b\\s*:\\s*`);
let braceCount = 0;
let foundKey = false;
for (let i = 0; i < lines.length; i++) {
if (keyPattern.test(lines[i]) && !foundKey) {
foundKey = true;
startLineNumber = i + 1;
startColumn = lines[i].indexOf(key) + 1;
if (lines[i].includes("{}")) {
endLineNumber = startLineNumber;
endColumn = lines[i].indexOf("{}") + 3;
break;
}
const line = lines[i].slice(startColumn + key.length);
if (line.includes("{") || line.includes("[")) {
braceCount = 1;
} else {
endLineNumber = i + 1;
endColumn = lines[i].length + 1;
break;
}
} else if (foundKey) {
braceCount += (lines[i].match(/{/g) || []).length;
braceCount += (lines[i].match(/\[/g) || []).length;
braceCount -= (lines[i].match(/}/g) || []).length;
braceCount -= (lines[i].match(/]/g) || []).length;
if (braceCount === 0) {
endLineNumber = i + 1;
endColumn = lines[i].lastIndexOf("}") !== -1 ? lines[i].lastIndexOf("}") + 2 : lines[i].length + 1;
break;
}
}
}
return {
startColumn,
endColumn,
startLineNumber,
endLineNumber
};
};
const replaceOctalEscapeSequences = (str) => {
const octalRegex = /\\([0-7]{1,3})/g;
return str.replace(octalRegex, (match, p1) => {
const octalValue = parseInt(p1, 8);
const char = String.fromCharCode(octalValue);
return char;
});
};

4

package.json
{
"name": "@domql/utils",
"version": "2.5.95",
"version": "2.5.97",
"license": "MIT",

@@ -26,3 +26,3 @@ "type": "module",

},
"gitHead": "8ac5f539ad4739c7baa30dd68cb7d6f94e70aa3c",
"gitHead": "0dd6029804289092faf4f94a4b853486233baf34",
"devDependencies": {

@@ -29,0 +29,0 @@ "@babel/core": "^7.12.0"

@@ -57,1 +57,71 @@ 'use strict'

}
export const findKeyPosition = (str, key) => {
const lines = str.split('\n')
let startLineNumber = -1
let endLineNumber = -1
let startColumn = -1
let endColumn = -1
const keyPattern = new RegExp(`\\b${key}\\b\\s*:\\s*`)
let braceCount = 0
let foundKey = false
for (let i = 0; i < lines.length; i++) {
if (keyPattern.test(lines[i]) && !foundKey) {
foundKey = true
startLineNumber = i + 1
startColumn = lines[i].indexOf(key) + 1
// Check if the value is an empty object
if (lines[i].includes('{}')) {
endLineNumber = startLineNumber
endColumn = lines[i].indexOf('{}') + 3
break
}
// Check if the value starts with '{' (object) or '[' (array)
const line = lines[i].slice(startColumn + key.length)
if (line.includes('{') || line.includes('[')) {
braceCount = 1
} else {
endLineNumber = i + 1
endColumn = lines[i].length + 1
break
}
} else if (foundKey) {
braceCount += (lines[i].match(/{/g) || []).length
braceCount += (lines[i].match(/\[/g) || []).length
braceCount -= (lines[i].match(/}/g) || []).length
braceCount -= (lines[i].match(/]/g) || []).length
// If braceCount is 0 and we find the end of the object/array
if (braceCount === 0) {
endLineNumber = i + 1
endColumn = lines[i].lastIndexOf('}') !== -1 ? lines[i].lastIndexOf('}') + 2 : lines[i].length + 1
break
}
}
}
return {
startColumn,
endColumn,
startLineNumber,
endLineNumber
}
}
export const replaceOctalEscapeSequences = (str) => {
// Regex to match octal escape sequences
const octalRegex = /\\([0-7]{1,3})/g
// Replace each match with the corresponding character
return str.replace(octalRegex, (match, p1) => {
// Convert the octal value to a decimal integer
const octalValue = parseInt(p1, 8)
// Convert the decimal value to the corresponding character
const char = String.fromCharCode(octalValue)
return char
})
}
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