MCPcopy
hub / github.com/jaredpalmer/formik / copyArrayLike

Function copyArrayLike

packages/formik/src/FieldArray.tsx:109–120  ·  view source on GitHub ↗
(arrayLike: ArrayLike<any>)

Source from the content-addressed store, hash-verified

107};
108
109const copyArrayLike = (arrayLike: ArrayLike<any>) => {
110 if (!arrayLike) {
111 return [];
112 } else if (Array.isArray(arrayLike)) {
113 return [...arrayLike];
114 } else {
115 const maxIndex = Object.keys(arrayLike)
116 .map(key => parseInt(key))
117 .reduce((max, el) => (el > max ? el : max), 0);
118 return Array.from({ ...arrayLike, length: maxIndex + 1 });
119 }
120};
121
122const createAlterationHandler = (
123 alteration: boolean | Function,

Callers 7

moveFunction · 0.85
swapFunction · 0.85
insertFunction · 0.85
replaceFunction · 0.85
createAlterationHandlerFunction · 0.85
FieldArrayInnerClass · 0.85
removeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…