MCPcopy
hub / github.com/bgrins/TinyColor / createCommon

Function createCommon

npm/deno_asserts@0.168.0.mjs:73–84  ·  view source on GitHub ↗
(A, B, reverse)

Source from the content-addressed store, hash-verified

71const COMMON = 2;
72const ADDED = 3;
73function createCommon(A, B, reverse) {
74 const common = [];
75 if (A.length === 0 || B.length === 0) return [];
76 for(let i = 0; i < Math.min(A.length, B.length); i += 1){
77 if (A[reverse ? A.length - i - 1 : i] === B[reverse ? B.length - i - 1 : i]) {
78 common.push(A[reverse ? A.length - i - 1 : i]);
79 } else {
80 return common;
81 }
82 }
83 return common;
84}
85function diff(A, B) {
86 const prefixCommon = createCommon(A, B);
87 const suffixCommon = createCommon(A.slice(prefixCommon.length), B.slice(prefixCommon.length), true).reverse();

Callers 1

diffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…