UNPKG

object-path-resolver

Version:
23 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPathResolver = exports.pathResolver = void 0; const convert_path_to_array_of_keys_1 = require("./convert-path-to-array-of-keys"); const get_value_from_obj_with_path_1 = require("./get-value-from-obj-with-path"); const defaultOptions = { missing: undefined, sync: false, allowPrototypeAccess: false, }; function pathResolver(obj, path, options = defaultOptions) { const parsedPath = (0, convert_path_to_array_of_keys_1.convertPathToArrayOfKeys)(path, { allowPrototypeAccess: options.allowPrototypeAccess }); if (options.sync) { return (0, get_value_from_obj_with_path_1.syncGetValueFromObjWithPath)(obj, parsedPath, options); } return (0, get_value_from_obj_with_path_1.getValueFromObjWithPath)(obj, parsedPath, options); } exports.pathResolver = pathResolver; function createPathResolver(options = defaultOptions) { return (value, path) => pathResolver(value, path, options); } exports.createPathResolver = createPathResolver; //# sourceMappingURL=index.js.map