MCPcopy Index your code
hub / github.com/subquery/subql / findArrayIndicesTsManifest

Function findArrayIndicesTsManifest

packages/cli/src/utils/utils.ts:172–180  ·  view source on GitHub ↗
(content: string, key: string)

Source from the content-addressed store, hash-verified

170 return pairs;
171}
172export function findArrayIndicesTsManifest(content: string, key: string): [number, number] {
173 const start = content.indexOf(`${key}:`);
174 if (start === -1) throw new Error(`${key} not found`);
175 const pairs = findMatchingIndices(content, '[', ']', start);
176
177 if (pairs.length === 0) throw new Error(`${key} contains unbalanced brackets`);
178
179 return pairs[0];
180}
181export function replaceArrayValueInTsManifest(content: string, key: string, newValue: string): string {
182 const [startIndex, endIndex] = findArrayIndicesTsManifest(content, key);
183 return content.slice(0, startIndex) + newValue + content.slice(endIndex + 1);

Callers 2

Calls 1

findMatchingIndicesFunction · 0.85

Tested by

no test coverage detected