import { assert } from "../assert.js";
import { resolvePathByArray } from "./resolvePathByArray.js";


/**
 *
 * @param {object} object
 * @param {string} path separated with forward slash "/"
 * @param {function} [missingPropertyHandler] Allows custom handling of missing properties
 * @returns {*}
 * @throws {Error} if a path can not be resolved
 */
export function resolvePath(object, path, missingPropertyHandler) {
    assert.isString(path, 'path');
    assert.isObject(object, "object");

    const parts = path.split("/");

    return resolvePathByArray(object, parts, missingPropertyHandler);
}
