MCPcopy
hub / github.com/webpack/webpack / similarity

Function similarity

lib/util/deterministicGrouping.js:33–42  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

31 * @returns {number} the similarity as number
32 */
33const similarity = (a, b) => {
34 const l = Math.min(a.length, b.length);
35 let dist = 0;
36 for (let i = 0; i < l; i++) {
37 const ca = a.charCodeAt(i);
38 const cb = b.charCodeAt(i);
39 dist += Math.max(0, 10 - Math.abs(ca - cb));
40 }
41 return dist;
42};
43
44/**
45 * Returns the common part and a single char for the difference.

Callers 2

popNodesMethod · 0.85
getSimilaritiesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected