UNPKG

@modern-kit/utils

Version:
20 lines (16 loc) 468 B
'use strict'; var validatorIsNil = require('../../validator/isNil/index.cjs'); function get(obj, path, defaultValue) { const paths = path.replace(/\?/g, "").split("."); let result = obj; for (let i = 0; i < paths.length; i++) { const currentPath = paths[i]; if (validatorIsNil.isNil(result[currentPath])) { return defaultValue; } result = result[currentPath]; } return result; } exports.get = get; //# sourceMappingURL=index.cjs.map