@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
35 lines • 1.04 kB
JavaScript
import { NodeType } from "../types/index.mjs";
const getNodeChildren = (section) => {
if (typeof section === "string") {
return section;
}
if (typeof section === "number") {
return section;
}
if (typeof section === "boolean") {
return section;
}
if (typeof section?.nodeType === "string") {
const typedNode = section;
const content = typedNode[typedNode.nodeType];
if (typedNode.nodeType === NodeType.Translation || typedNode.nodeType === NodeType.Enumeration || typedNode.nodeType === NodeType.Condition || typedNode.nodeType === NodeType.Insertion || typedNode.nodeType === NodeType.File) {
const firstKey = Object.keys(content)[0];
return content[firstKey];
}
if (typedNode.nodeType === NodeType.Nested) {
return void 0;
}
return content;
}
if (!section || typeof section !== "object") {
return section;
}
if (Array.isArray(section)) {
return section[0];
}
return section;
};
export {
getNodeChildren
};
//# sourceMappingURL=getNodeChildren.mjs.map