@pathmaker-digital/pmd-utilities - v2.2.6
    Preparing search index...

    Function unless

    • Executes a function only if the condition is false. This is an inverse of an if statement, providing a concise way to execute logic only if the condition is not met.

      Parameters

      • cond: boolean

        The condition to check.

      • fn: () => void

        The function to execute if the condition is false.

      Returns void

      // Will log "Access denied" because the condition is false
      unless(user.isAdmin, () => console.log("Access denied"));
      // Will not log anything because the condition is true
      unless(user.isAdmin, () => console.log("Access denied"));