getPropertyValue()

in core/utils.js [391:412]


    getPropertyValue(target, propertyPath, defaultValue = undefined) {
        if (!exports.isString(propertyPath) || exports.string.isEmptyOrWhitespace(propertyPath)) {
            throw new Error("Invalid propertyPath.");
        }

        if (exports.isNullOrUndefined(target)) {
            return defaultValue;
        }

        const propertyNames = propertyPath.split(".");
        let targetObj = target;

        for (const name of propertyNames) {
            if (targetObj === undefined || targetObj === null) {
                return defaultValue;
            } else {
                targetObj = targetObj[name];
            }
        }

        return targetObj;
    }