@domql/utils 2.29.70 → 2.29.71
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.
- package/dist/cjs/object.js +19 -1
- package/dist/esm/object.js +19 -1
- package/object.js +21 -2
- package/package.json +2 -2
package/dist/cjs/object.js
CHANGED
|
@@ -267,10 +267,28 @@ const objectToString = (obj = {}, indent = 0) => {
|
|
|
267
267
|
if (obj === null || typeof obj !== "object") {
|
|
268
268
|
return String(obj);
|
|
269
269
|
}
|
|
270
|
+
const spaces = " ".repeat(indent);
|
|
271
|
+
if (Array.isArray(obj)) {
|
|
272
|
+
if (obj.length === 0) return "[]";
|
|
273
|
+
let str2 = "[\n";
|
|
274
|
+
for (const element of obj) {
|
|
275
|
+
if ((0, import_types.isObjectLike)(element)) {
|
|
276
|
+
str2 += `${spaces} ${objectToString(element, indent + 1)},
|
|
277
|
+
`;
|
|
278
|
+
} else if ((0, import_types.isString)(element)) {
|
|
279
|
+
str2 += `${spaces} '${element}',
|
|
280
|
+
`;
|
|
281
|
+
} else {
|
|
282
|
+
str2 += `${spaces} ${element},
|
|
283
|
+
`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
str2 += `${spaces}]`;
|
|
287
|
+
return str2;
|
|
288
|
+
}
|
|
270
289
|
if (Object.keys(obj).length === 0) {
|
|
271
290
|
return "{}";
|
|
272
291
|
}
|
|
273
|
-
const spaces = " ".repeat(indent);
|
|
274
292
|
let str = "{\n";
|
|
275
293
|
for (const [key, value] of Object.entries(obj)) {
|
|
276
294
|
const keyNotAllowdChars = (0, import_string.stringIncludesAny)(key, [
|
package/dist/esm/object.js
CHANGED
|
@@ -235,10 +235,28 @@ const objectToString = (obj = {}, indent = 0) => {
|
|
|
235
235
|
if (obj === null || typeof obj !== "object") {
|
|
236
236
|
return String(obj);
|
|
237
237
|
}
|
|
238
|
+
const spaces = " ".repeat(indent);
|
|
239
|
+
if (Array.isArray(obj)) {
|
|
240
|
+
if (obj.length === 0) return "[]";
|
|
241
|
+
let str2 = "[\n";
|
|
242
|
+
for (const element of obj) {
|
|
243
|
+
if (isObjectLike(element)) {
|
|
244
|
+
str2 += `${spaces} ${objectToString(element, indent + 1)},
|
|
245
|
+
`;
|
|
246
|
+
} else if (isString(element)) {
|
|
247
|
+
str2 += `${spaces} '${element}',
|
|
248
|
+
`;
|
|
249
|
+
} else {
|
|
250
|
+
str2 += `${spaces} ${element},
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
str2 += `${spaces}]`;
|
|
255
|
+
return str2;
|
|
256
|
+
}
|
|
238
257
|
if (Object.keys(obj).length === 0) {
|
|
239
258
|
return "{}";
|
|
240
259
|
}
|
|
241
|
-
const spaces = " ".repeat(indent);
|
|
242
260
|
let str = "{\n";
|
|
243
261
|
for (const [key, value] of Object.entries(obj)) {
|
|
244
262
|
const keyNotAllowdChars = stringIncludesAny(key, [
|
package/object.js
CHANGED
|
@@ -297,17 +297,36 @@ export const deepStringifyWithMaxDepth = (
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
export const objectToString = (obj = {}, indent = 0) => {
|
|
300
|
-
// Handle
|
|
300
|
+
// Handle null or primitive case
|
|
301
301
|
if (obj === null || typeof obj !== 'object') {
|
|
302
302
|
return String(obj)
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
const spaces = ' '.repeat(indent)
|
|
306
|
+
|
|
307
|
+
// Handle array case
|
|
308
|
+
if (Array.isArray(obj)) {
|
|
309
|
+
if (obj.length === 0) return '[]'
|
|
310
|
+
|
|
311
|
+
let str = '[\n'
|
|
312
|
+
for (const element of obj) {
|
|
313
|
+
if (isObjectLike(element)) {
|
|
314
|
+
str += `${spaces} ${objectToString(element, indent + 1)},\n`
|
|
315
|
+
} else if (isString(element)) {
|
|
316
|
+
str += `${spaces} '${element}',\n`
|
|
317
|
+
} else {
|
|
318
|
+
str += `${spaces} ${element},\n`
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
str += `${spaces}]`
|
|
322
|
+
return str
|
|
323
|
+
}
|
|
324
|
+
|
|
305
325
|
// Handle empty object case
|
|
306
326
|
if (Object.keys(obj).length === 0) {
|
|
307
327
|
return '{}'
|
|
308
328
|
}
|
|
309
329
|
|
|
310
|
-
const spaces = ' '.repeat(indent)
|
|
311
330
|
let str = '{\n'
|
|
312
331
|
|
|
313
332
|
for (const [key, value] of Object.entries(obj)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.71",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
|
|
25
25
|
"prepublish": "npm run build; npm run copy:package:cjs"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "2ccd453fff2f5e00cf6df90d9562d075bf436c9b",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/core": "^7.27.1"
|
|
30
30
|
}
|