Function
assertCommonItems
(
a: Array<unknown> | string,
b: Array<unknown> | string,
nCommon: number,
aCommon: number,
bCommon: number,
)
Source from the content-addressed store, hash-verified
| 139 | }; |
| 140 | |
| 141 | const assertCommonItems = ( |
| 142 | a: Array<unknown> | string, |
| 143 | b: Array<unknown> | string, |
| 144 | nCommon: number, |
| 145 | aCommon: number, |
| 146 | bCommon: number, |
| 147 | ) => { |
| 148 | for (; nCommon !== 0; nCommon -= 1, aCommon += 1, bCommon += 1) { |
| 149 | if (a[aCommon] !== b[bCommon]) { |
| 150 | throw new Error( |
| 151 | `output item is not common for aCommon=${aCommon} and bCommon=${bCommon}`, |
| 152 | ); |
| 153 | } |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | // Given lengths of sequences and input function to compare items at indexes, |
| 158 | // return number of differences according to baseline greedy forward algorithm. |
Tested by
no test coverage detected