(chunks: string[])
| 144 | } |
| 145 | |
| 146 | function parseTransformedExtension(chunks: string[]): TransformedExtension { |
| 147 | let lang: UnicodeLanguageId | undefined |
| 148 | try { |
| 149 | lang = parseUnicodeLanguageId(chunks) |
| 150 | } catch { |
| 151 | // Try just parsing tfield |
| 152 | } |
| 153 | const fields: KV[] = [] |
| 154 | while (chunks.length && TKEY_REGEX.test(chunks[0])) { |
| 155 | const key = chunks.shift()! |
| 156 | const value = [] |
| 157 | while (chunks.length && ALPHANUM_3_8.test(chunks[0])) { |
| 158 | value.push(chunks.shift()) |
| 159 | } |
| 160 | if (!value.length) { |
| 161 | throw new RangeError(`Missing tvalue for tkey "${key}"`) |
| 162 | } |
| 163 | fields.push([key, value.join(SEPARATOR)]) |
| 164 | } |
| 165 | if (fields.length) { |
| 166 | return { |
| 167 | type: 't', |
| 168 | fields, |
| 169 | lang, |
| 170 | } |
| 171 | } |
| 172 | throw new RangeError('Malformed transformed_extension') |
| 173 | } |
| 174 | function parsePuExtension(chunks: string[]): PuExtension { |
| 175 | const exts = [] |
| 176 | while (chunks.length && ALPHANUM_1_8.test(chunks[0])) { |
no test coverage detected