@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
18 lines • 824 B
JavaScript
import { NodeType } from "../types/index.mjs";
const getContentNodeByKeyPath = (dictionaryContent, keyPath) => {
let currentValue = structuredClone(dictionaryContent);
for (const keyObj of keyPath) {
if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {
currentValue = currentValue?.[keyObj.key];
} else if (keyObj.type === NodeType.Translation || keyObj.type === NodeType.Condition || keyObj.type === NodeType.Enumeration) {
currentValue = currentValue?.[keyObj.type][keyObj.key];
} else if (keyObj.type === NodeType.Markdown || keyObj.type === NodeType.Insertion || keyObj.type === NodeType.File) {
currentValue = currentValue?.[keyObj.type];
}
}
return currentValue;
};
export {
getContentNodeByKeyPath
};
//# sourceMappingURL=getContentNodeByKeyPath.mjs.map