MCPcopy Create free account
hub / github.com/Autodesk/react-base-table / getValue

Function getValue

src/utils.js:158–182  ·  view source on GitHub ↗
(object, path, defaultValue)

Source from the content-addressed store, hash-verified

156
157// changed from https://github.com/sindresorhus/dot-prop/blob/master/index.js
158export function getValue(object, path, defaultValue) {
159 if (object === null || typeof object !== 'object' || typeof path !== 'string') {
160 return defaultValue;
161 }
162
163 const pathArray = getPathSegments(path);
164
165 for (let i = 0; i < pathArray.length; i++) {
166 if (!Object.prototype.propertyIsEnumerable.call(object, pathArray[i])) {
167 return defaultValue;
168 }
169
170 object = object[pathArray[i]];
171
172 if (object === undefined || object === null) {
173 if (i !== pathArray.length - 1) {
174 return defaultValue;
175 }
176
177 break;
178 }
179 }
180
181 return object;
182}
183
184// copied from https://www.30secondsofcode.org/js/s/debounce
185export const debounce = (fn, ms = 0) => {

Callers 1

BaseTable.jsFile · 0.90

Calls 1

getPathSegmentsFunction · 0.85

Tested by

no test coverage detected