mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-10-21 13:49:31 +02:00
Refactor: removed redundancy on array conversion
This commit is contained in:
@@ -47,14 +47,7 @@ const convertObjectToXml = (
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach((item) => {
|
value.forEach((item) => {
|
||||||
xml += `${getIndentation(options, depth)}<${keyString}>`;
|
xml += `${getIndentation(options, depth)}<${keyString}>`;
|
||||||
xml +=
|
xml += convertObjectToXml(item, options, depth + 1);
|
||||||
typeof item === 'object' && item !== null
|
|
||||||
? `${newline}${convertObjectToXml(
|
|
||||||
item,
|
|
||||||
options,
|
|
||||||
depth + 1
|
|
||||||
)}${getIndentation(options, depth)}`
|
|
||||||
: `${escapeXml(String(item))}`;
|
|
||||||
xml += `</${keyString}>${newline}`;
|
xml += `</${keyString}>${newline}`;
|
||||||
});
|
});
|
||||||
} else if (value === null) {
|
} else if (value === null) {
|
||||||
@@ -66,6 +59,8 @@ const convertObjectToXml = (
|
|||||||
xml += `${getIndentation(options, depth)}<${keyString}>${newline}`;
|
xml += `${getIndentation(options, depth)}<${keyString}>${newline}`;
|
||||||
xml += convertObjectToXml(value, options, depth + 1);
|
xml += convertObjectToXml(value, options, depth + 1);
|
||||||
xml += `${getIndentation(options, depth)}</${keyString}>${newline}`;
|
xml += `${getIndentation(options, depth)}</${keyString}>${newline}`;
|
||||||
|
|
||||||
|
// All other types are tre
|
||||||
} else {
|
} else {
|
||||||
xml += `${getIndentation(options, depth)}<${keyString}>${escapeXml(
|
xml += `${getIndentation(options, depth)}<${keyString}>${escapeXml(
|
||||||
String(value)
|
String(value)
|
||||||
|
Reference in New Issue
Block a user