MCPcopy Create free account
hub / github.com/CashScript/cashscript / deriveSourceText

Function deriveSourceText

packages/utils/src/bitauth-script.ts:208–219  ·  view source on GitHub ↗
(tag: SourceTagEntry, locationData: FullLocationData, sourceLines: string[])

Source from the content-addressed store, hash-verified

206}
207
208function deriveSourceText(tag: SourceTagEntry, locationData: FullLocationData, sourceLines: string[]): string {
209 const headerLine = getDisplayLine(locationData[tag.startIndex]);
210 const singleLineLocations = range(tag.startIndex, tag.endIndex)
211 .map((idx) => locationData[idx].location)
212 .filter((loc) => loc.start.line === loc.end.line && loc.start.column !== loc.end.column);
213
214 if (singleLineLocations.length === 0) return '';
215
216 const startCol = Math.min(...singleLineLocations.map((loc) => loc.start.column));
217 const endCol = Math.max(...singleLineLocations.map((loc) => loc.end.column));
218 return sourceLines[headerLine - 1].substring(startCol, endCol).trim();
219}

Callers 1

tagDescriptionFunction · 0.85

Calls 2

getDisplayLineFunction · 0.85
rangeFunction · 0.85

Tested by

no test coverage detected