UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

23 lines (21 loc) 1.18 kB
import * as NodeTypes from "@intlayer/types/nodeType"; //#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 === NodeTypes.MARKDOWN || typedNode.nodeType === NodeTypes.HTML) return content; if (typedNode.nodeType === NodeTypes.TRANSLATION || typedNode.nodeType === NodeTypes.ENUMERATION || typedNode.nodeType === NodeTypes.PLURAL || typedNode.nodeType === NodeTypes.CONDITION || typedNode.nodeType === NodeTypes.INSERTION || typedNode.nodeType === NodeTypes.GENDER || typedNode.nodeType === NodeTypes.FILE) return content[Object.keys(content)[0]]; if (typedNode.nodeType === NodeTypes.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