forked from MapComplete/MapComplete
Chore: improve typing
This commit is contained in:
parent
d01f830632
commit
01f1fbf89a
5 changed files with 38 additions and 14 deletions
|
@ -332,9 +332,12 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
* @param toKey
|
||||
* @constructor
|
||||
*/
|
||||
public static DedupOnId<T>(arr: T[], toKey: (t: T) => string): T[] {
|
||||
public static DedupOnId<T = { id: string }>(arr: T[], toKey?: (t: T) => string): T[] {
|
||||
const uniq: T[] = []
|
||||
const seen = new Set<string>()
|
||||
if (toKey === undefined) {
|
||||
toKey = (item) => item["id"]
|
||||
}
|
||||
for (const img of arr) {
|
||||
if (!img) {
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue