Fix sortie de conteneur

This commit is contained in:
Vincent Vandemeulebrouck
2021-05-07 01:47:51 +02:00
parent 6eb79c3ec7
commit 56c82d935a
6 changed files with 83 additions and 77 deletions

View File

@ -63,9 +63,9 @@ export class Misc {
}
}
static classify(items, classifier = it => it.type, transform = it => it) {
static classify(items, classifier = it => it.type) {
let itemsBy = {};
Misc.classifyInto(itemsBy, items, classifier, transform);
Misc.classifyInto(itemsBy, items, classifier);
return itemsBy;
}
@ -80,7 +80,7 @@ export class Misc {
return itemsBy;
}
static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) {
static classifyInto(itemsBy, items, classifier = it => it.type) {
for (const item of items) {
const classification = classifier(item);
let list = itemsBy[classification];
@ -88,11 +88,8 @@ export class Misc {
list = [];
itemsBy[classification] = list;
}
list.push(transform(item));
list.push(item);
}
for (const [key, list] of Object.entries(itemsBy)) {
list.sort();
};
}
static rollOneOf(array) {