UNPKG

@intlayer/core

Version:

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

26 lines (24 loc) 1.43 kB
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); let __intlayer_types = require("@intlayer/types"); //#region src/dictionaryManipulator/getEmptyNode.ts const getEmptyNode = (section) => { if (typeof section === "string") return ""; if (typeof section === "number") return 0; if (typeof section === "boolean") return true; 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 || typedNode.nodeType === __intlayer_types.NodeType.Insertion) return getEmptyNode(content); if (typedNode.nodeType === __intlayer_types.NodeType.Nested) return "dictionary-key"; if (typedNode.nodeType === __intlayer_types.NodeType.File) return "file/path"; if (typedNode.nodeType === __intlayer_types.NodeType.Markdown) return getEmptyNode(typedNode); return content; } if (!section || typeof section !== "object") return section; if (Array.isArray(section)) return section.map(getEmptyNode); const mappedSectionObject = Object.entries(section).map(([key, value]) => [key, getEmptyNode(value)]); return Object.fromEntries(mappedSectionObject); }; //#endregion exports.getEmptyNode = getEmptyNode; //# sourceMappingURL=getEmptyNode.cjs.map