(left: Value[], right: Value[], comp: VFn)
| 322 | return merge(left, right, comp); |
| 323 | }; |
| 324 | const merge = async (left: Value[], right: Value[], comp: VFn): Promise<Value[]> => { |
| 325 | const result: Value[] = []; |
| 326 | let leftIndex = 0; |
| 327 | let rightIndex = 0; |
| 328 | while (leftIndex < left.length && rightIndex < right.length) { |
| 329 | const l = left[leftIndex]!; |
| 330 | const r = right[rightIndex]!; |
| 331 | const compValue = await opts.call(comp, [l, r]); |
| 332 | assertNumber(compValue); |
| 333 | if (compValue.value <= 0) { |
| 334 | result.push(left[leftIndex]!); |
| 335 | leftIndex++; |
| 336 | } else { |
| 337 | result.push(right[rightIndex]!); |
| 338 | rightIndex++; |
| 339 | } |
| 340 | } |
| 341 | return result.concat(left.slice(leftIndex)).concat(right.slice(rightIndex)); |
| 342 | }; |
| 343 | |
| 344 | assertFunction(comp); |
| 345 | assertArray(target); |
no test coverage detected