MCPcopy Create free account
hub / github.com/react-component/select / dig

Function dig

src/utils/valueUtil.ts:57–91  ·  view source on GitHub ↗
(list: OptionType[], isGroupOption: boolean)

Source from the content-addressed store, hash-verified

55 } = fillFieldNames(fieldNames, false);
56
57 function dig(list: OptionType[], isGroupOption: boolean) {
58 if (!Array.isArray(list)) {
59 return;
60 }
61
62 list.forEach((data) => {
63 if (isGroupOption || !(fieldOptions in data)) {
64 const value = data[fieldValue];
65
66 // Option
67 flattenList.push({
68 key: getKey(data, flattenList.length),
69 groupOption: isGroupOption,
70 data,
71 label: data[fieldLabel],
72 value,
73 });
74 } else {
75 let grpLabel = data[groupLabel];
76 if (grpLabel === undefined && childrenAsData) {
77 grpLabel = data.label;
78 }
79
80 // Option Group
81 flattenList.push({
82 key: getKey(data, flattenList.length),
83 group: true,
84 data,
85 label: grpLabel,
86 });
87
88 dig(data[fieldOptions], true);
89 }
90 });
91 }
92
93 dig(options, false);
94

Callers 1

flattenOptionsFunction · 0.70

Calls 1

getKeyFunction · 0.85

Tested by

no test coverage detected