You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mediarepo/mediarepo-ui/src/app/utils/list-utils.ts

16 lines
392 B
TypeScript

export function enumerate<T>(list: T[]): [number, T][] {
const enumeratedEntries = [];
for (let i = 0; i < list.length; i++) {
enumeratedEntries.push([i, list[i]] as [number, T]);
}
return enumeratedEntries;
}
export function removeByValue<T>(list: T[], entry: T) {
const index = list.indexOf(entry);
if (index >= 0) {
list.splice(index, 1);
}
}