(A: T[], B: T[])
| 37 | * ``` |
| 38 | */ |
| 39 | export function createCommon<T>(A: T[], B: T[]): T[] { |
| 40 | const common: T[] = []; |
| 41 | if (A.length === 0 || B.length === 0) return []; |
| 42 | for (let i = 0; i < Math.min(A.length, B.length); i += 1) { |
| 43 | const a = A[i]; |
| 44 | const b = B[i]; |
| 45 | if (a !== undefined && a === b) { |
| 46 | common.push(a); |
| 47 | } else { |
| 48 | return common; |
| 49 | } |
| 50 | } |
| 51 | return common; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Asserts that the value is a {@linkcode FarthestPoint}. |