MCPcopy
hub / github.com/vitejs/vite / numberToPos

Function numberToPos

packages/vite/src/node/utils.ts:471–484  ·  view source on GitHub ↗
(source: string, offset: number | Pos)

Source from the content-addressed store, hash-verified

469}
470
471export function numberToPos(source: string, offset: number | Pos): Pos {
472 if (typeof offset !== 'number') return offset
473 if (offset > source.length) {
474 throw new Error(
475 `offset is longer than source length! offset ${offset} > length ${source.length}`,
476 )
477 }
478
479 const lines = source.slice(0, offset).split(splitRE)
480 return {
481 line: lines.length,
482 column: lines[lines.length - 1].length,
483 }
484}
485
486const MAX_DISPLAY_LEN = 120
487const ELLIPSIS = '...'

Callers 6

ssrTransformScriptFunction · 0.90
generateBundleFunction · 0.90
_formatLogMethod · 0.90
generateBundleFunction · 0.90
utils.spec.tsFile · 0.90
generateCodeFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected