mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-24 23:31:50 +02:00
22 lines
420 B
JavaScript
22 lines
420 B
JavaScript
const lookup = {};
|
|
|
|
const arrays = [
|
|
[0, 1, 2, 3, 4, 4, 4, 4],
|
|
[5, 6, 7, 8, 9, 10, 11, 11],
|
|
[2, 7, 10, 12],
|
|
[0, 7, 10, 14]
|
|
];
|
|
|
|
const reduced = arrays.map((array, index) => {
|
|
for(let i=array.length-1; i>=0; i--) {
|
|
let value = array[i];
|
|
let knownIndex = (lookup[value] = lookup[value] ?? index);
|
|
if (knownIndex < index) {
|
|
array.splice(i,1);
|
|
}
|
|
}
|
|
return array;
|
|
});
|
|
|
|
console.log(reduced);
|