(fileContent: string)
| 34 | * Parses the text protobuf format for slicing strategies. |
| 35 | */ |
| 36 | const parseSlicingStrategy = (fileContent: string): number[][] => { |
| 37 | const slices: number[][] = []; |
| 38 | let currentSlice: number[] | null = null; |
| 39 | |
| 40 | for (const line of fileContent.split('\n')) { |
| 41 | const trimmedLine = line.trim(); |
| 42 | if (trimmedLine === 'subsets {') { |
| 43 | if (currentSlice) slices.push(currentSlice); |
| 44 | currentSlice = []; |
| 45 | } else if (trimmedLine.startsWith('codepoints:')) { |
| 46 | const codepointMatch = trimmedLine.match(/codepoints: (\d+)/); |
| 47 | if (codepointMatch && currentSlice) { |
| 48 | currentSlice.push(parseInt(codepointMatch[1] ?? '0', 10)); |
| 49 | } |
| 50 | } else if (trimmedLine === '}') { |
| 51 | if (currentSlice && currentSlice.length > 0) { |
| 52 | slices.push(currentSlice); |
| 53 | currentSlice = null; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | // The files list subsets in reverse priority order. We want to process them in priority order. |
| 58 | return slices.reverse(); |
| 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * Generates the complete subset data map from raw file contents provided in the config. |
no outgoing calls
no test coverage detected