chore: reformat with 2 spaces

This commit is contained in:
Johannes Loher 2023-07-10 22:23:13 +02:00
parent d659e4bed9
commit 7670d7f808
No known key found for this signature in database
GPG key ID: 7CB0A9FB553DA045
1577 changed files with 70010 additions and 70042 deletions

View file

@ -9,14 +9,14 @@ type LogLevel = "debug" | "info" | "warning" | "error";
type LoggingFunction = (...data: unknown[]) => void;
const getLoggingFunction = (type: LogLevel = "info"): LoggingFunction => {
const log = { debug: console.debug, info: console.info, warning: console.warn, error: console.error }[type];
return (...data: unknown[]) => log(loggingContext, loggingSeparator, ...data);
const log = { debug: console.debug, info: console.info, warning: console.warn, error: console.error }[type];
return (...data: unknown[]) => log(loggingContext, loggingSeparator, ...data);
};
export const logger = Object.freeze({
debug: getLoggingFunction("debug"),
info: getLoggingFunction("info"),
warn: getLoggingFunction("warning"),
error: getLoggingFunction("error"),
getLoggingFunction,
debug: getLoggingFunction("debug"),
info: getLoggingFunction("info"),
warn: getLoggingFunction("warning"),
error: getLoggingFunction("error"),
getLoggingFunction,
});

View file

@ -14,14 +14,14 @@
* @returns {asserts value}
*/
export function enforce(value, message) {
if (!value) {
if (!message) {
message =
getGameSafe()?.i18n.localize("DS4.ErrorUnexpectedError") ??
"There was an unexpected error in the Dungeonslayers 4 system. For more details, please take a look at the console (F12).";
}
throw message instanceof Error ? message : new Error(message);
if (!value) {
if (!message) {
message =
getGameSafe()?.i18n.localize("DS4.ErrorUnexpectedError") ??
"There was an unexpected error in the Dungeonslayers 4 system. For more details, please take a look at the console (F12).";
}
throw message instanceof Error ? message : new Error(message);
}
}
/**
@ -30,8 +30,8 @@ export function enforce(value, message) {
* @returns {Canvas}
*/
export function getCanvas() {
enforce(canvas instanceof Canvas && canvas.ready, getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"));
return canvas;
enforce(canvas instanceof Canvas && canvas.ready, getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"));
return canvas;
}
/**
@ -40,8 +40,8 @@ export function getCanvas() {
* @returns {Game}
*/
export function getGame() {
enforce(game instanceof Game, "Game is not initialized yet.");
return game;
enforce(game instanceof Game, "Game is not initialized yet.");
return game;
}
/**
@ -49,7 +49,7 @@ export function getGame() {
* @returns {Game | undefined}
*/
export function getGameSafe() {
return game instanceof Game ? game : undefined;
return game instanceof Game ? game : undefined;
}
/**
@ -57,5 +57,5 @@ export function getGameSafe() {
* @returns {Notifications | undefined}
*/
export function getNotificationsSafe() {
return ui.notifications instanceof Notifications ? ui.notifications : undefined;
return ui.notifications instanceof Notifications ? ui.notifications : undefined;
}