(spec: string, count: number)
| 51 | } |
| 52 | |
| 53 | export function parseDimIndex(spec: string, count: number): string[] { |
| 54 | if (spec.indexOf(',') !== -1) { |
| 55 | const components = spec.split(',').map((c) => c.trim()); |
| 56 | if (components.length !== count) { |
| 57 | throw new Error('dimIndex Element has invalid specification.'); |
| 58 | } |
| 59 | return components; |
| 60 | } |
| 61 | |
| 62 | if (/^([0-9]+)\-([0-9]+)$/i.test(spec)) { |
| 63 | const parts = spec.split('-').map((p) => parseInteger(p)); |
| 64 | const start = parts[0]; |
| 65 | const end = parts[1]; |
| 66 | |
| 67 | const numElements = end - start + 1; |
| 68 | if (numElements < count) { |
| 69 | throw new Error('dimIndex Element has invalid specification.'); |
| 70 | } |
| 71 | |
| 72 | const components = []; |
| 73 | for (let i = 0; i < count; i++) { |
| 74 | components.push(`${start + i}`); |
| 75 | } |
| 76 | |
| 77 | return components; |
| 78 | } |
| 79 | |
| 80 | if (/^[a-zA-Z]\-[a-zA-Z]$/.test(spec)) { |
| 81 | const start = spec.charCodeAt(0); |
| 82 | const end = spec.charCodeAt(2); |
| 83 | |
| 84 | const numElements = end - start + 1; |
| 85 | if (numElements < count) { |
| 86 | throw new Error('dimIndex Element has invalid specification.'); |
| 87 | } |
| 88 | |
| 89 | const components = []; |
| 90 | for (let i = 0; i < count; i++) { |
| 91 | components.push(String.fromCharCode(start + i)); |
| 92 | } |
| 93 | |
| 94 | return components; |
| 95 | } |
| 96 | |
| 97 | return []; |
| 98 | } |
nothing calls this directly
no test coverage detected