UNPKG

@intlayer/core

Version:

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

38 lines (36 loc) 1.43 kB
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); let __intlayer_types = require("@intlayer/types"); //#region src/dictionaryManipulator/updateNodeChildren.ts const updateNodeChildren = (section, newChildren) => { if (typeof section === "string") return newChildren; if (typeof section === "number") return newChildren; if (typeof section === "boolean") return newChildren; if (typeof section?.nodeType === "string") { const typedNode = section; const content = typedNode[typedNode.nodeType]; if (typedNode.nodeType === __intlayer_types.NodeType.Translation || typedNode.nodeType === __intlayer_types.NodeType.Enumeration || typedNode.nodeType === __intlayer_types.NodeType.Condition) { const newContent = Object.entries(content).reduce((acc, [key]) => { acc[key] = newChildren; return acc; }, {}); return { ...typedNode, [typedNode.nodeType]: newContent }; } if (typedNode.nodeType === __intlayer_types.NodeType.Nested) return typedNode; return { ...typedNode, [typedNode.nodeType]: newChildren }; } if (!section || typeof section !== "object") return newChildren; if (Array.isArray(section)) return section.map(() => newChildren); return Object.entries(section).reduce((acc, [key]) => ({ ...acc, [key]: newChildren }), {}); }; //#endregion exports.updateNodeChildren = updateNodeChildren; //# sourceMappingURL=updateNodeChildren.cjs.map