MCPcopy Create free account
hub / github.com/denoland/std / createCommon

Function createCommon

internal/diff.ts:39–52  ·  view source on GitHub ↗
(A: T[], B: T[])

Source from the content-addressed store, hash-verified

37 * ```
38 */
39export 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}.

Callers 2

fnFunction · 0.90
diffFunction · 0.85

Calls 2

minMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected