MCPcopy Index your code
hub / github.com/formatjs/formatjs / calculateLineColFromOffset

Function calculateLineColFromOffset

packages/cli-lib/extract.ts:119–130  ·  view source on GitHub ↗
(
  text: string,
  start?: number
)

Source from the content-addressed store, hash-verified

117} & Pick<Opts, 'onMsgExtracted' | 'onMetaExtracted'>
118
119function calculateLineColFromOffset(
120 text: string,
121 start?: number
122): Pick<ExtractedMessageDescriptor, 'line' | 'col'> {
123 if (!start) {
124 return {line: 1, col: 1}
125 }
126 const chunk = text.slice(0, start)
127 const lines = chunk.split('\n')
128 const lastLine = lines[lines.length - 1]
129 return {line: lines.length, col: lastLine.length}
130}
131
132function isBuiltinFormatter(
133 format: ExtractOpts['format']

Callers 1

onMsgExtractedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected