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

Method length

src/MagicString.ts:1238–1246  ·  view source on GitHub ↗

* Returns the length of the generated string, counting only content attached to the original characters. * Content outside the string body (`s.prepend()`/`s.append()`, and inserts before the first or after the last * character) is not counted, so this can differ from `s.toString().length`.

()

Source from the content-addressed store, hash-verified

1236 * character) is not counted, so this can differ from `s.toString().length`.
1237 */
1238 length(): number {
1239 let chunk: Chunk | null = this.firstChunk
1240 let length = 0
1241 while (chunk) {
1242 length += chunk.intro.length + chunk.content.length + chunk.outro.length
1243 chunk = chunk.next
1244 }
1245 return length
1246 }
1247
1248 /**
1249 * Removes empty lines from the start and end.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected