MCPcopy
hub / github.com/final-form/final-form / getIn

Function getIn

src/structure/getIn.ts:4–21  ·  view source on GitHub ↗
(state: object, complexKey: string)

Source from the content-addressed store, hash-verified

2import type { GetIn } from "../types";
3
4const getIn: GetIn = (state: object, complexKey: string): any => {
5 // Intentionally using iteration rather than recursion
6 const path = toPath(complexKey);
7 let current: any = state;
8 for (let i = 0; i < path.length; i++) {
9 const key = path[i];
10 if (
11 current === undefined ||
12 current === null ||
13 typeof current !== "object" ||
14 (Array.isArray(current) && isNaN(Number(key)))
15 ) {
16 return undefined;
17 }
18 current = current[key];
19 }
20 return current;
21};
22
23export default getIn;

Callers 9

publishFieldStateFunction · 0.85
changeValueFunction · 0.85
renameFieldFunction · 0.85
runFieldLevelValidationFunction · 0.85
forEachErrorFunction · 0.85
processErrorsFunction · 0.85
calculateNextFormStateFunction · 0.85
createFormFunction · 0.85
getIn.test.tsFile · 0.85

Calls 1

toPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…