(value: string)
| 47 | } |
| 48 | |
| 49 | export function decodeBox(value: string): Box { |
| 50 | const points = value.match(/\(.*?\)/g) || []; |
| 51 | |
| 52 | if (points.length !== 2) { |
| 53 | throw new Error( |
| 54 | `Invalid Box: "${value}". Box must have only 2 point, ${points.length} given.`, |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | const [a, b] = points; |
| 59 | |
| 60 | try { |
| 61 | return { |
| 62 | a: decodePoint(a), |
| 63 | b: decodePoint(b), |
| 64 | }; |
| 65 | } catch (e) { |
| 66 | throw new Error( |
| 67 | `Invalid Box: "${value}" : ${(e instanceof Error ? e.message : e)}`, |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | export function decodeBoxArray(value: string) { |
| 73 | return parseArray(value, decodeBox, ";"); |
no test coverage detected