( expr: MathJsonExpression | null | undefined )
| 430 | if (rhsName === op) return [op, lhs, ...operands(rhs)]; |
| 431 | return [op, lhs, rhs]; |
| 432 | } |
| 433 | |
| 434 | /** Return the elements of a sequence, or null if the expression is not a sequence. The sequence can be optionally enclosed by a`["Delimiter"]` expression */ |
| 435 | export function getSequence( |
| 436 | expr: MathJsonExpression | null | undefined |
| 437 | ): ReadonlyArray<MathJsonExpression> | null { |
| 438 | if (expr === null || expr === undefined) return null; |
| 439 | |
| 440 | let h = operator(expr); |
| 441 | if (h === 'Delimiter') { |
| 442 | expr = operand(expr, 1); |
| 443 | if (expr === null) return []; |
| 444 | h = operator(expr); |
| 445 | if (h !== 'Sequence') return [expr!]; |
| 446 | } |
| 447 | |
| 448 | if (h !== 'Sequence') return null; |
| 449 | |
| 450 | return operands(expr); |
| 451 | } |
no test coverage detected