MCPcopy
hub / github.com/subquery/subql / splitArrayString

Function splitArrayString

packages/cli/src/utils/utils.ts:220–238  ·  view source on GitHub ↗
(arrayStr: string)

Source from the content-addressed store, hash-verified

218}
219
220export function splitArrayString(arrayStr: string): string[] {
221 // Remove the starting and ending square brackets
222 const content = arrayStr.trim().slice(1, -1).trim();
223 const pairs: [number, number][] = [];
224 let lastEndIndex = 0;
225
226 while (lastEndIndex < content.length) {
227 const newPairs = findMatchingIndices(content, '{', '}', lastEndIndex);
228 if (newPairs.length === 0) break;
229 pairs.push(newPairs[0]);
230 lastEndIndex = newPairs[0][1] + 1;
231 }
232
233 return pairs.map(([start, end]) => {
234 // Extract the string and further process to remove excess whitespace
235 const extracted = content.slice(start, end + 1).trim();
236 return extracted.replace(/\s+/g, ' ');
237 });
238}
239
240// Cold validate on ts manifest, for generate scaffold command
241export function validateEthereumTsManifest(manifest: string): boolean {

Callers 2

tsExtractorFunction · 0.90

Calls 2

findMatchingIndicesFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected