@domql/utils 2.3.137 → 2.3.138
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 -4
- package/object.js +16 -4
- package/package.json +2 -2
package/dist/cjs/object.js
CHANGED
|
@@ -167,13 +167,28 @@ const objectToString = (obj, indent = 0) => {
|
|
|
167
167
|
const spaces = " ".repeat(indent);
|
|
168
168
|
let str = "{\n";
|
|
169
169
|
for (const [key, value] of Object.entries(obj)) {
|
|
170
|
-
const keyAllowdChars = (0, import_string.stringIncludesAny)(key, ["-", ":"]);
|
|
170
|
+
const keyAllowdChars = (0, import_string.stringIncludesAny)(key, ["-", ":", "@", ".", "!"]);
|
|
171
171
|
const stringedKey = keyAllowdChars ? `'${key}'` : key;
|
|
172
172
|
str += `${spaces} ${stringedKey}: `;
|
|
173
|
-
if (
|
|
173
|
+
if ((0, import_types.isArray)(value)) {
|
|
174
|
+
str += "[\n";
|
|
175
|
+
for (const element of value) {
|
|
176
|
+
if ((0, import_types.isObject)(element) && element !== null) {
|
|
177
|
+
str += `${spaces} ${objectToString(element, indent + 2)},
|
|
178
|
+
`;
|
|
179
|
+
} else if ((0, import_types.isString)(element)) {
|
|
180
|
+
str += `${spaces} '${element}',
|
|
181
|
+
`;
|
|
182
|
+
} else {
|
|
183
|
+
str += `${spaces} ${element},
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
str += `${spaces} ]`;
|
|
188
|
+
} else if ((0, import_types.isObject)(value)) {
|
|
174
189
|
str += objectToString(value, indent + 1);
|
|
175
|
-
} else if (
|
|
176
|
-
str += `'${value}'`;
|
|
190
|
+
} else if ((0, import_types.isString)(value)) {
|
|
191
|
+
str += (0, import_string.stringIncludesAny)(value, ["\n", "'"]) ? `\`${value}\`` : `'${value}'`;
|
|
177
192
|
} else {
|
|
178
193
|
str += value;
|
|
179
194
|
}
|
package/object.js
CHANGED
|
@@ -141,14 +141,26 @@ export const objectToString = (obj, indent = 0) => {
|
|
|
141
141
|
let str = '{\n'
|
|
142
142
|
|
|
143
143
|
for (const [key, value] of Object.entries(obj)) {
|
|
144
|
-
const keyAllowdChars = stringIncludesAny(key, ['-', ':'])
|
|
144
|
+
const keyAllowdChars = stringIncludesAny(key, ['-', ':', '@', '.', '!'])
|
|
145
145
|
const stringedKey = keyAllowdChars ? `'${key}'` : key
|
|
146
146
|
str += `${spaces} ${stringedKey}: `
|
|
147
147
|
|
|
148
|
-
if (
|
|
148
|
+
if (isArray(value)) {
|
|
149
|
+
str += '[\n'
|
|
150
|
+
for (const element of value) {
|
|
151
|
+
if (isObject(element) && element !== null) {
|
|
152
|
+
str += `${spaces} ${objectToString(element, indent + 2)},\n`
|
|
153
|
+
} else if (isString(element)) {
|
|
154
|
+
str += `${spaces} '${element}',\n`
|
|
155
|
+
} else {
|
|
156
|
+
str += `${spaces} ${element},\n`
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
str += `${spaces} ]`
|
|
160
|
+
} else if (isObject(value)) {
|
|
149
161
|
str += objectToString(value, indent + 1)
|
|
150
|
-
} else if (
|
|
151
|
-
str += `'${value}'`
|
|
162
|
+
} else if (isString(value)) {
|
|
163
|
+
str += stringIncludesAny(value, ['\n', '\'']) ? `\`${value}\`` : `'${value}'`
|
|
152
164
|
} else {
|
|
153
165
|
str += value
|
|
154
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.138",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@domql/key": "latest",
|
|
24
24
|
"@domql/tags": "latest"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "066e799de6a79c164756c90b4d68e16b226523df",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|