* Picks a node by rounding down and using the given parity. This function is * useful for picking the picking eg the key in a sequence of key-value pairs * @param parentFinder The finder to use to determine whether the parent is a * match * @param parity The parity that we're looking for * @ret
(parentFinder: NodeFinder, parity: 0 | 1)
| 25 | * @returns A node finder |
| 26 | */ |
| 27 | function parityNodeFinder(parentFinder: NodeFinder, parity: 0 | 1) { |
| 28 | return indexNodeFinder( |
| 29 | parentFinder, |
| 30 | (nodeIndex: number) => Math.floor(nodeIndex / 2) * 2 + parity |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | function mapParityNodeFinder(parity: 0 | 1) { |
| 35 | return parityNodeFinder(patternFinder("map_lit"), parity); |
no test coverage detected