/
1Rrd0
/
Course
Обзор
Документация
Войти
/
1Rrd0
/
Course
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/mongoose/lib/helpers/path/setDottedPath.js
33 строки
585 B
dima
2
13 дек 2025, 10:58
13 дек 2025, 10:58
ce5a48e
Код
Авторство
О чём код?
'use strict'; const specialProperties = require('../specialProperties'); module.exports = function setDottedPath(obj, path, val) { if (path.indexOf('.') === -1) { if (specialProperties.has(path)) { return; } obj[path] = val; return; } const parts = path.split('.'); const last = parts.pop(); let cur = obj; for (const part of parts) { if (specialProperties.has(part)) { continue; } if (cur[part] == null) { cur[part] = {}; } cur = cur[part]; } if (!specialProperties.has(last)) { cur[last] = val; } };