@domql/utils 2.5.170 → 2.5.178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -231,6 +231,12 @@ const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "")
231
231
  return stringified;
232
232
  };
233
233
  const objectToString = (obj = {}, indent = 0) => {
234
+ if (obj === null || typeof obj !== "object") {
235
+ return String(obj);
236
+ }
237
+ if (Object.keys(obj).length === 0) {
238
+ return "{}";
239
+ }
234
240
  const spaces = " ".repeat(indent);
235
241
  let str = "{\n";
236
242
  for (const [key, value] of Object.entries(obj)) {
@@ -202,6 +202,12 @@ const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "")
202
202
  return stringified;
203
203
  };
204
204
  const objectToString = (obj = {}, indent = 0) => {
205
+ if (obj === null || typeof obj !== "object") {
206
+ return String(obj);
207
+ }
208
+ if (Object.keys(obj).length === 0) {
209
+ return "{}";
210
+ }
205
211
  const spaces = " ".repeat(indent);
206
212
  let str = "{\n";
207
213
  for (const [key, value] of Object.entries(obj)) {
package/object.js CHANGED
@@ -238,6 +238,16 @@ export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path
238
238
  }
239
239
 
240
240
  export const objectToString = (obj = {}, indent = 0) => {
241
+ // Handle empty object case
242
+ if (obj === null || typeof obj !== 'object') {
243
+ return String(obj)
244
+ }
245
+
246
+ // Handle empty object case
247
+ if (Object.keys(obj).length === 0) {
248
+ return '{}'
249
+ }
250
+
241
251
  const spaces = ' '.repeat(indent)
242
252
  let str = '{\n'
243
253
 
@@ -252,7 +262,6 @@ export const objectToString = (obj = {}, indent = 0) => {
252
262
  if (isObjectLike(element) && element !== null) {
253
263
  str += `${spaces} ${objectToString(element, indent + 2)},\n`
254
264
  } else if (isString(element)) {
255
- // if (element.includes('\n')) str += spaces + ' ' + '`' + element + '`,\n'
256
265
  str += `${spaces} '${element}',\n`
257
266
  } else {
258
267
  str += `${spaces} ${element},\n`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.170",
3
+ "version": "2.5.178",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -25,7 +25,7 @@
25
25
  "build": "npm run build:cjs; npm run build:esm",
26
26
  "prepublish": "rimraf -I dist; npm run build; npm run copy:package:cjs"
27
27
  },
28
- "gitHead": "44f9d2c4157170a03784d6abca2eee3604b97270",
28
+ "gitHead": "b274eb76e068d125b38f9e617fcfb98d657eafbd",
29
29
  "devDependencies": {
30
30
  "@babel/core": "^7.12.0"
31
31
  }