UNPKG

@nesvet/n

Version:
20 lines 759 B
export function setPath(object, path, value) { if (object && path) { if (path.includes(".")) { const keys = path.split("."); let subObject = object; // eslint-disable-line @typescript-eslint/no-explicit-any for (let i = 0; i < keys.length - 1; i++) { const key = keys[i]; const subObjectValue = subObject[key]; subObject = (subObjectValue && typeof subObjectValue == "object") ? subObjectValue : (subObject[key] = {}); } return (subObject[keys.at(-1)] = value); } return (object[path] = value); } return null; } //# sourceMappingURL=setPath.js.map