(operations: IOperation[])
| 26 | * @param operations Operations Array |
| 27 | */ |
| 28 | export function composeOperations(operations: IOperation[]): IOperation[] { |
| 29 | return operations.reduce<IOperation[]>((pre, cur) => { |
| 30 | delete cur.resourceType; |
| 31 | delete cur.revision; |
| 32 | delete cur.fieldTypeMap; |
| 33 | if (pre.length) { |
| 34 | const preOp = pre.pop(); |
| 35 | const { operation, isComposed } = composeOperation(cur, preOp!); |
| 36 | if (operation != null) { |
| 37 | pre.push(operation); |
| 38 | if (!isComposed) { |
| 39 | pre.push(cur); |
| 40 | } |
| 41 | } |
| 42 | } else { |
| 43 | pre.push(cur); |
| 44 | } |
| 45 | return pre; |
| 46 | }, []); |
| 47 | } |
| 48 | |
| 49 | export function composeOperation(preOperation: IOperation, curOperation: IOperation): { operation: IOperation | null; isComposed: boolean } { |
| 50 | if ( |
no test coverage detected