MCPcopy Index your code
hub / github.com/react/react / getInObject

Function getInObject

packages/react-devtools-shared/src/utils.js:610–629  ·  view source on GitHub ↗
(object: Object, path: Array<string | number>)

Source from the content-addressed store, hash-verified

608}
609
610export function getInObject(object: Object, path: Array<string | number>): any {
611 return path.reduce((reduced: Object, attr: any): any => {
612 if (reduced) {
613 if (hasOwnProperty.call(reduced, attr)) {
614 return reduced[attr];
615 }
616 if (typeof reduced[Symbol.iterator] === 'function') {
617 // Convert iterable to array and return array[index]
618 //
619 // TRICKY
620 // Don't use [...spread] syntax for this purpose.
621 // This project uses @babel/plugin-transform-spread in "loose" mode which only works with Array values.
622 // Other types (e.g. typed arrays, Sets) will not spread correctly.
623 return Array.from(reduced)[attr];
624 }
625 }
626
627 return null;
628 }, object);
629}
630
631export function deletePathInObject(
632 object: Object,

Callers 12

fillInPathFunction · 0.90
hydrateFunction · 0.90
storeAsGlobalFunction · 0.90
storeAsGlobalFunction · 0.90
inspectElementFunction · 0.90
deletePathInObjectFunction · 0.85
renamePathInObjectFunction · 0.85
setInObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected