From 22923855f96fcb301f041d1cef2ce5578cb1449b Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 23 Jul 2021 12:48:11 +0200 Subject: [PATCH] Ad documentation for `enforce` --- src/module/utils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/module/utils.ts b/src/module/utils.ts index 668a9bf..a3038fe 100644 --- a/src/module/utils.ts +++ b/src/module/utils.ts @@ -4,6 +4,14 @@ import { getGameSafe } from "./helpers"; +/** + * Tests if the given `value` is truthy. + * + * If it is not truthy, an {@link Error} is thrown, which depends on the given `message` parameter: + * - If `message` is a string`, it is used to construct a new {@link Error} which then is thrown. + * - If `message` is an instance of {@link Error}, it is thrown. + * - If `message` is `undefined`, an {@link Error} with a default message is thrown. + */ export function enforce(value: unknown, message?: string | Error): asserts value { if (!value) { if (!message) {