(op: string, a: Json, b: Json)
| 374 | } |
| 375 | |
| 376 | function flatBinaryOp(op: string, a: Json, b: Json): Json { |
| 377 | const ops: Json[] = []; |
| 378 | for (const x of [a, b]) { |
| 379 | if (Array.isArray(x) && x[0] === op) ops.push(...(x as Json[]).slice(1)); |
| 380 | else ops.push(x); |
| 381 | } |
| 382 | return [op, ...ops]; |
| 383 | } |
| 384 | |
| 385 | function flatBinary(op: 'Add' | 'Multiply', a: Json, b: Json): Json { |
| 386 | return flatBinaryOp(op, a, b); |
no test coverage detected