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

Function plainTopLevelEndPosition

packages/icu-messageformat-parser/parser.ts:137–168  ·  view source on GitHub ↗
(message: string)

Source from the content-addressed store, hash-verified

135}
136
137function plainTopLevelEndPosition(message: string): Position | null {
138 if (message.length === 0) {
139 return null
140 }
141 let line = 1
142 let column = 1
143 for (let offset = 0; offset < message.length; ) {
144 const code = message.charCodeAt(offset)
145 switch (code) {
146 case 35: // #
147 case 39: // '
148 case 60: // <
149 case 123: // {
150 case 125: // }
151 return null
152 }
153 if (code === 10 /* '\n' */) {
154 line++
155 column = 1
156 offset++
157 } else {
158 column++
159 if (code >= 0xd800 && code <= 0xdbff && offset + 1 < message.length) {
160 const next = message.charCodeAt(offset + 1)
161 offset += next >= 0xdc00 && next <= 0xdfff ? 2 : 1
162 } else {
163 offset++
164 }
165 }
166 }
167 return {offset: message.length, line, column}
168}
169
170export class Parser {
171 private message: string

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected