1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Apply suggestions from SonarQube (#2340)

This commit is contained in:
Michael Telatynski
2022-05-03 22:40:57 +01:00
committed by GitHub
parent b86630f0e3
commit 8be30acb11
19 changed files with 86 additions and 96 deletions

View File

@@ -465,7 +465,7 @@ export function defer<T = void>(): IDeferred<T> {
export async function promiseMapSeries<T>(
promises: Array<T | Promise<T>>,
fn: (t: T) => void,
fn: (t: T) => Promise<unknown> | void, // if async/promise we don't care about the type as we only await resolution
): Promise<void> {
for (const o of promises) {
await fn(await o);
@@ -473,7 +473,7 @@ export async function promiseMapSeries<T>(
}
export function promiseTry<T>(fn: () => T | Promise<T>): Promise<T> {
return new Promise((resolve) => resolve(fn()));
return Promise.resolve(fn());
}
// Creates and awaits all promises, running no more than `chunkSize` at the same time
@@ -676,7 +676,13 @@ export function prevString(s: string, alphabet = DEFAULT_ALPHABET): string {
export function lexicographicCompare(a: string, b: string): number {
// Dev note: this exists because I'm sad that you can use math operators on strings, so I've
// hidden the operation in this function.
return (a < b) ? -1 : ((a === b) ? 0 : 1);
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
}
const collator = new Intl.Collator();