MCPcopy Create free account
hub / github.com/HelloCSV/HelloCSV / trimExamplesByCharacterLimit

Function trimExamplesByCharacterLimit

src/mapper/utils.ts:124–143  ·  view source on GitHub ↗
(examples: string[])

Source from the content-addressed store, hash-verified

122}
123
124function trimExamplesByCharacterLimit(examples: string[]) {
125 const trimmedExamples = [...examples];
126 let totalCharacters = trimmedExamples.reduce(
127 (acc, curr) => acc + curr.length,
128 0
129 );
130
131 while (
132 totalCharacters > MAX_CHARACTERS_IN_MAPPING_EXAMPLES &&
133 trimmedExamples.length > 1
134 ) {
135 trimmedExamples.pop();
136 totalCharacters = trimmedExamples.reduce(
137 (acc, curr) => acc + curr.length,
138 0
139 );
140 }
141
142 return trimmedExamples;
143}
144
145export function useMappingAvailableSelectOptions(
146 sheetDefinitions: SheetDefinition[],

Callers 1

calculateMappingExamplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected