UNPKG

@wordpress/core-data

Version:
38 lines (36 loc) 1.46 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/core-data/src/utils/get-nested-value.js var get_nested_value_exports = {}; __export(get_nested_value_exports, { default: () => getNestedValue }); module.exports = __toCommonJS(get_nested_value_exports); function getNestedValue(object, path, defaultValue) { if (!object || typeof object !== "object" || typeof path !== "string" && !Array.isArray(path)) { return object; } const normalizedPath = Array.isArray(path) ? path : path.split("."); let value = object; normalizedPath.forEach((fieldName) => { value = value?.[fieldName]; }); return value !== void 0 ? value : defaultValue; } //# sourceMappingURL=get-nested-value.js.map