( expr: MathJsonExpression | null | undefined )
| 200 | } |
| 201 | |
| 202 | function keyValuePair( |
| 203 | expr: MathJsonExpression | null | undefined |
| 204 | ): null | [key: string, value: MathJsonExpression] { |
| 205 | const h = operator(expr); |
| 206 | if (h === 'KeyValuePair' || h === 'Tuple' || h === 'Pair') { |
| 207 | const [k, v] = operands(expr); |
| 208 | const key = stringValue(k); |
| 209 | if (!key) return null; |
| 210 | return [key, v ?? 'Nothing']; |
| 211 | } |
| 212 | |
| 213 | return null; |
| 214 | } |
| 215 | |
| 216 | // Parse the expression either as: |
| 217 | // - a `Dictionary` expression |
no test coverage detected