Make nodes editable: norms, goals and keyword triggers

This commit is contained in:
Twirre
2025-11-13 10:50:12 +00:00
committed by Gerla, J. (Justin)
parent f534f0cefa
commit aeaf526797
14 changed files with 580 additions and 100 deletions

View File

@@ -0,0 +1,19 @@
/**
* Find the indices of all elements that occur more than once.
*
* @param array The array to search for duplicates.
* @returns An array of indices where an element occurs more than once, in no particular order.
*/
export default function duplicateIndices<T>(array: T[]): number[] {
const positions = new Map<T, number[]>();
array.forEach((value, i) => {
if (!positions.has(value)) positions.set(value, []);
positions.get(value)!.push(i);
});
// flatten all index lists with more than one element
return Array.from(positions.values())
.filter(idxs => idxs.length > 1)
.flat();
}