Ad documentation for enforce

This commit is contained in:
Johannes Loher 2021-07-23 12:48:11 +02:00
parent 2b3dd9b859
commit 22923855f9

View file

@ -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) {