@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
22 lines (20 loc) • 1.06 kB
JavaScript
import { NodeType } from "@intlayer/types";
//#region src/dictionaryManipulator/getNodeChildren.ts
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.Gender || typedNode.nodeType === NodeType.File || typedNode.nodeType === NodeType.Markdown) return content[Object.keys(content)[0]];
if (typedNode.nodeType === NodeType.Nested) return;
return content;
}
if (!section || typeof section !== "object") return section;
if (Array.isArray(section)) return section[0];
return section;
};
//#endregion
export { getNodeChildren };
//# sourceMappingURL=getNodeChildren.mjs.map