(x: MathJSON, out = new Set<string>())
| 183 | } |
| 184 | |
| 185 | /** All wildcard symbols (`_…`) appearing in a MathJSON tree. */ |
| 186 | export function collectWildcards(x: MathJSON, out = new Set<string>()): Set<string> { |
| 187 | if (typeof x === 'string' && x.startsWith('_')) out.add(x); |
| 188 | else if (Array.isArray(x)) for (const y of x) collectWildcards(y, out); |
| 189 | return out; |
| 190 | } |
| 191 | |
| 192 | /** All symbol-position strings appearing in a MathJSON tree. */ |
no test coverage detected