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

Function getSeparatedContent

src/utils/valueUtil.ts:118–139  ·  view source on GitHub ↗
(text: string, tokens: string[], end?: number)

Source from the content-addressed store, hash-verified

116}
117
118export const getSeparatedContent = (text: string, tokens: string[], end?: number): string[] => {
119 if (!tokens || !tokens.length) {
120 return null;
121 }
122 let match = false;
123 const separate = (str: string, [token, ...restTokens]: string[]): string[] => {
124 if (!token) {
125 return [str];
126 }
127 const list = str.split(token);
128 match = match || list.length > 1;
129 return list
130 .reduce((prevList, unitStr) => [...prevList, ...separate(unitStr, restTokens)], [])
131 .filter(Boolean);
132 };
133 const list = separate(text, tokens);
134 if (match) {
135 return typeof end !== 'undefined' ? list.slice(0, end) : list;
136 } else {
137 return null;
138 }
139};

Callers 2

onInternalSearchFunction · 0.90
utils.test.jsxFile · 0.90

Calls 1

separateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…