@s-libs/js-core
    Preparing search index...

    Function assert

    • Throws an error if condition is falsy, and acts as a type guard.

      Parameters

      • condition: any
      • Optionalmessage: string

        The message to set in the error that is thrown

        class ProblemLogger {
        problem?: string;

        log() {
        assert(this.problem, "You must set problem before logging it");

        // now typescript knows `this.problem` is truthy, so we can safely call methods on it
        console.log(problem.toUpperCase());
        }
        }

      Returns asserts condition