"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasProperty = exports.getObjectValue = exports.getArrayValue = void 0;
const errors_1 = require("../types/errors");
const getArrayValue = (obj, key, errorMessage) => {
    if (obj === undefined) {
        throw new errors_1.UnexpectedIndexError(errorMessage || `Cannot get key "${key}" value from empty array`);
    }
    const value = obj[key];
    if (value === undefined) {
        // eslint-disable-next-line no-console
        console.trace();
        throw new errors_1.UnexpectedIndexError(errorMessage || `Cannot get key "${key}" value from array`);
    }
    return value;
};
exports.getArrayValue = getArrayValue;
const getObjectValue = (obj, key, errorMessage) => {
    if (obj === undefined) {
        throw new errors_1.UnexpectedIndexError(errorMessage || `Cannot get key "${key}" value from empty object`);
    }
    const value = obj[key];
    if (value === undefined) {
        // eslint-disable-next-line no-console
        console.trace();
        throw new errors_1.UnexpectedIndexError(errorMessage || `Cannot get key "${key}" value from object`);
    }
    return value;
};
exports.getObjectValue = getObjectValue;
const hasProperty = (obj, property) => typeof obj === 'object' && obj !== null && property in obj;
exports.hasProperty = hasProperty;
//# sourceMappingURL=accessors.js.map