( expr: MathJsonExpression | null | undefined )
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * The operator of a function is symbol. |
| 112 | * |
| 113 | * Return an empty string if the expression is not a function. |
| 114 | * |
| 115 | * Examples: |
| 116 | * * `["Negate", 5]` -> `"Negate"` |
| 117 | */ |
| 118 | export function operator( |
| 119 | expr: MathJsonExpression | null | undefined |
| 120 | ): MathJsonSymbol { |
| 121 | if (Array.isArray(expr)) return expr[0]; |
| 122 | |
| 123 | if (expr === null || expr === undefined) return ''; |
| 124 | |
| 125 | if (isFunctionObject(expr)) return expr.fn[0]; |
| 126 | |
| 127 | return ''; |
no test coverage detected