Apply editorconfig

This commit is contained in:
Andras Schmelczer 2025-12-07 13:38:23 +00:00
parent ad3191957a
commit b05e415acf
131 changed files with 16404 additions and 13617 deletions

View file

@ -1,5 +1,5 @@
export function assert(value: boolean, message: string): asserts value {
if (!value) {
throw new Error(message);
}
if (!value) {
throw new Error(message);
}
}

View file

@ -1,3 +1,3 @@
export function choose<T>(values: T[]): T {
return values[Math.floor(Math.random() * values.length)];
return values[Math.floor(Math.random() * values.length)];
}

View file

@ -3,11 +3,11 @@ import assert from "node:assert";
import { randomCasing } from "./random-casing";
describe("randomCasing", () => {
it("simple test", () => {
const input =
"hello, this is a really long string with a lot of characters";
const result = randomCasing(input);
assert.strictEqual(result.toLowerCase(), input.toLowerCase());
assert.notStrictEqual(result, input);
});
it("simple test", () => {
const input =
"hello, this is a really long string with a lot of characters";
const result = randomCasing(input);
assert.strictEqual(result.toLowerCase(), input.toLowerCase());
assert.notStrictEqual(result, input);
});
});

View file

@ -1,10 +1,10 @@
export function randomCasing(str: string): string {
const chars = str.split("");
const randomCasedChars = chars.map((char) => {
if (Math.random() < 0.5) {
return char.toUpperCase();
}
return char.toLowerCase();
});
return randomCasedChars.join("");
const chars = str.split("");
const randomCasedChars = chars.map((char) => {
if (Math.random() < 0.5) {
return char.toUpperCase();
}
return char.toLowerCase();
});
return randomCasedChars.join("");
}

View file

@ -1,3 +1,3 @@
export async function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
return new Promise((resolve) => setTimeout(resolve, ms));
}

View file

@ -1,16 +1,16 @@
export async function withTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
operationName: string
promise: Promise<T>,
timeoutMs: number,
operationName: string
): Promise<T> {
return Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(() => {
reject(
new Error(`${operationName} timed out after ${timeoutMs}ms`)
);
}, timeoutMs)
)
]);
return Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(() => {
reject(
new Error(`${operationName} timed out after ${timeoutMs}ms`)
);
}, timeoutMs)
)
]);
}