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

@domql/utils

Package Overview
Dependencies
Maintainers
3
Versions
198
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.3.126 to 2.3.137

dist/cjs/string.js

1

dist/cjs/index.js

@@ -25,1 +25,2 @@ "use strict";

__reExport(utils_exports, require("./log.js"), module.exports);
__reExport(utils_exports, require("./string.js"), module.exports);

@@ -38,6 +38,8 @@ "use strict";

mergeIfExisted: () => mergeIfExisted,
objectToString: () => objectToString,
overwrite: () => overwrite,
overwriteDeep: () => overwriteDeep,
overwriteShallow: () => overwriteShallow,
removeFromObject: () => removeFromObject
removeFromObject: () => removeFromObject,
stringToObject: () => stringToObject
});

@@ -48,2 +50,3 @@ module.exports = __toCommonJS(object_exports);

var import_array = require("./array.js");
var import_string = require("./string.js");
const exec = (param, element, state, context) => {

@@ -165,2 +168,21 @@ if ((0, import_types.isFunction)(param)) {

};
const objectToString = (obj, indent = 0) => {
const spaces = " ".repeat(indent);
let str = "{\n";
for (const [key, value] of Object.entries(obj)) {
const keyAllowdChars = (0, import_string.stringIncludesAny)(key, ["-", ":"]);
const stringedKey = keyAllowdChars ? `'${key}'` : key;
str += `${spaces} ${stringedKey}: `;
if (typeof value === "object" && value !== null) {
str += objectToString(value, indent + 1);
} else if (typeof value === "string") {
str += `'${value}'`;
} else {
str += value;
}
str += ",\n";
}
str += `${spaces}}`;
return str;
};
const detachFunctionsFromObject = (obj, detached = {}) => {

@@ -236,2 +258,12 @@ for (const prop in obj) {

};
const stringToObject = (str) => {
let obj;
try {
obj = import_globals.window.eval("(" + str + ")");
} catch (e) {
console.warn(e);
}
if (obj)
return obj;
};
const diffObjects = (original, objToDiff, cache) => {

@@ -238,0 +270,0 @@ for (const e in objToDiff) {

@@ -10,1 +10,2 @@ 'use strict'

export * from './log.js'
export * from './string.js'

@@ -6,2 +6,3 @@ 'use strict'

import { mergeAndCloneIfArray, mergeArray } from './array.js'
import { stringIncludesAny } from './string.js'

@@ -139,2 +140,26 @@ export const exec = (param, element, state, context) => {

export const objectToString = (obj, indent = 0) => {
const spaces = ' '.repeat(indent)
let str = '{\n'
for (const [key, value] of Object.entries(obj)) {
const keyAllowdChars = stringIncludesAny(key, ['-', ':'])
const stringedKey = keyAllowdChars ? `'${key}'` : key
str += `${spaces} ${stringedKey}: `
if (typeof value === 'object' && value !== null) {
str += objectToString(value, indent + 1)
} else if (typeof value === 'string') {
str += `'${value}'`
} else {
str += value
}
str += ',\n'
}
str += `${spaces}}`
return str
}
/**

@@ -210,2 +235,11 @@ * Stringify object

export const stringToObject = (str) => {
let obj
try {
obj = window.eval('(' + str + ')') // eslint-disable-line
} catch (e) { console.warn(e) }
if (obj) return obj
}
export const diffObjects = (original, objToDiff, cache) => {

@@ -212,0 +246,0 @@ for (const e in objToDiff) {

4

package.json
{
"name": "@domql/utils",
"version": "2.3.126",
"version": "2.3.137",
"license": "MIT",

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

},
"gitHead": "6329de71d2e831d0efd9d59e765567aa8c563481",
"gitHead": "07ca3db13100667ebe3915db37a18b6e694a3ce3",
"devDependencies": {

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

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