UNPKG

@intlayer/core

Version:

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

33 lines (31 loc) 1.71 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); let _intlayer_types_nodeType = require("@intlayer/types/nodeType"); _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType); //#region src/dictionaryManipulator/removeContentNodeByKeyPath.ts const removeContentNodeByKeyPath = (dictionaryContent, keyPath) => { let currentValue = dictionaryContent; let parentValue = null; let lastKey = null; for (const keyObj of keyPath) { parentValue = currentValue; if (keyObj.type === _intlayer_types_nodeType.OBJECT || keyObj.type === _intlayer_types_nodeType.ARRAY) { lastKey = keyObj.key; currentValue = currentValue[keyObj.key]; } if (keyObj.type === _intlayer_types_nodeType.TRANSLATION || keyObj.type === _intlayer_types_nodeType.ENUMERATION || keyObj.type === _intlayer_types_nodeType.PLURAL || keyObj.type === _intlayer_types_nodeType.CONDITION) { lastKey = keyObj.type; currentValue = currentValue[keyObj.type][keyObj.key]; } if (keyObj.type === _intlayer_types_nodeType.MARKDOWN || keyObj.type === _intlayer_types_nodeType.REACT_NODE || keyObj.type === _intlayer_types_nodeType.HTML || keyObj.type === _intlayer_types_nodeType.INSERTION || keyObj.type === _intlayer_types_nodeType.FILE) { lastKey = keyObj.type; currentValue = currentValue[keyObj.type]; } } if (parentValue && lastKey !== null) if (Array.isArray(parentValue)) parentValue.splice(lastKey, 1); else delete parentValue[lastKey]; return dictionaryContent; }; //#endregion exports.removeContentNodeByKeyPath = removeContentNodeByKeyPath; //# sourceMappingURL=removeContentNodeByKeyPath.cjs.map