MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / mapValues

Function mapValues

packages/ui-components/src/Common/Select/utils.ts:9–24  ·  view source on GitHub ↗
(values: Array<unknown>)

Source from the content-addressed store, hash-verified

7 Boolean(values[0] && typeof values[0] === 'object' && 'value' in values[0]);
8
9export const mapValues = (values: Array<unknown>) => {
10 let mappedValues = values;
11
12 if (isStringArray(mappedValues)) {
13 mappedValues = mappedValues.map(value => ({
14 label: value,
15 value,
16 }));
17 }
18
19 if (isValuesArray(mappedValues)) {
20 return [{ items: mappedValues }];
21 }
22
23 return mappedValues;
24};

Callers 2

SelectFunction · 0.90
StatelessSelectFunction · 0.90

Calls 2

isStringArrayFunction · 0.85
isValuesArrayFunction · 0.85

Tested by

no test coverage detected