mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 16:45:16 +00:00
Automatically clean up old entries
This commit is contained in:
@ -21,4 +21,20 @@ export function findKey(object: Object, value: any): string {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all the entries of an array that meets a certain condition
|
||||
*
|
||||
* @param array Input array
|
||||
* @param callback Callback function to call on each element
|
||||
* of the array
|
||||
*/
|
||||
export function removeWhere<T>(array: Array<T>, callback: (el: T) => boolean) {
|
||||
var i = array.length;
|
||||
while (i--) {
|
||||
if (callback(array[i])) {
|
||||
array.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user