MCPcopy Index your code
hub / github.com/nodejs/node / deduplicateRelational

Function deduplicateRelational

test/fixtures/snapshot/typescript.js:981–999  ·  view source on GitHub ↗
(array, equalityComparer, comparer)

Source from the content-addressed store, hash-verified

979 }
980 ts.indicesOf = indicesOf;
981 function deduplicateRelational(array, equalityComparer, comparer) {
982 // Perform a stable sort of the array. This ensures the first entry in a list of
983 // duplicates remains the first entry in the result.
984 var indices = indicesOf(array);
985 stableSortIndices(array, indices, comparer);
986 var last = array[indices[0]];
987 var deduplicated = [indices[0]];
988 for (var i = 1; i < indices.length; i++) {
989 var index = indices[i];
990 var item = array[index];
991 if (!equalityComparer(last, item)) {
992 deduplicated.push(index);
993 last = item;
994 }
995 }
996 // restore original order
997 deduplicated.sort();
998 return deduplicated.map(function (i) { return array[i]; });
999 }
1000 function deduplicateEquality(array, equalityComparer) {
1001 var result = [];
1002 for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {

Callers 1

deduplicateFunction · 0.85

Calls 5

indicesOfFunction · 0.85
stableSortIndicesFunction · 0.85
sortMethod · 0.80
mapMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected