@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
21 lines (16 loc) • 624 B
JavaScript
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);
}