MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / _chunkAt

Method _chunkAt

src/MagicString.ts:1136–1147  ·  view source on GitHub ↗

* The chunk whose original range holds `index` (`chunk.start <= index < chunk.end`), * or `undefined` when `index` is at or past the end. Searches from the last * visited chunk so that scans over nearby indices stay cheap. * * @internal

(index: number)

Source from the content-addressed store, hash-verified

1134 * @internal
1135 */
1136 _chunkAt(index: number): Chunk | undefined {
1137 let chunk = this.byStart.get(index)
1138 if (chunk)
1139 return chunk
1140 chunk = this.lastSearchedChunk
1141 const searchForward = index >= chunk.end
1142 while (chunk && !chunk.contains(index))
1143 chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start)
1144 if (chunk)
1145 this.lastSearchedChunk = chunk
1146 return chunk
1147 }
1148
1149 /** @internal */
1150 _split(index: number): boolean | void {

Callers 2

sliceMethod · 0.95
_hasRemovedContentMethod · 0.95

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected