Use Map
This commit is contained in:
parent
f3c4b0e1e1
commit
452eec8a88
@ -491,15 +491,18 @@ function dictionaryErrorsShow(errors) {
|
|||||||
dialog.textContent = '';
|
dialog.textContent = '';
|
||||||
|
|
||||||
if (errors !== null && errors.length > 0) {
|
if (errors !== null && errors.length > 0) {
|
||||||
const uniqueErrors = {};
|
const uniqueErrors = new Map();
|
||||||
for (let e of errors) {
|
for (let e of errors) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
e = dictionaryErrorToString(e);
|
e = dictionaryErrorToString(e);
|
||||||
uniqueErrors[e] = hasOwn(uniqueErrors, e) ? uniqueErrors[e] + 1 : 1;
|
let count = uniqueErrors.get(e);
|
||||||
|
if (typeof count === 'undefined') {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
uniqueErrors.set(e, count + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const e in uniqueErrors) {
|
for (const [e, count] of uniqueErrors.entries()) {
|
||||||
const count = uniqueErrors[e];
|
|
||||||
const div = document.createElement('p');
|
const div = document.createElement('p');
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
div.textContent = `${e} `;
|
div.textContent = `${e} `;
|
||||||
|
Loading…
Reference in New Issue
Block a user