// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import { AssertionError } from "./assertion_error.ts";

/**
 * Make an assertion, error will be thrown if `expr` does not have truthy value.
 *
 * @example
 * ```ts
 * import { assert } from "@std/assert/assert";
 *
 * assert("hello".includes("ello")); // Doesn't throw
 * assert("hello".includes("world")); // Throws
 * ```
 */
export function assert(expr: unknown, msg = ""): asserts expr {
  if (!expr) {
    throw new AssertionError(msg);
  }
}

// denoCacheMetadata={"headers":{"nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","cache-control":"public, max-age=31536000, immutable","x-content-type-options":"nosniff","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","date":"Tue, 28 Jul 2026 12:31:15 GMT","cf-cache-status":"HIT","access-control-allow-origin":"*","etag":"\"900cef7cfbf3c84533ad9a974619593f\"","cross-origin-resource-policy":"cross-origin","server":"cloudflare","vary":"Origin","set-cookie":"__cf_bm=Y82kwPGoCl6nf_5fLOcwCftE9VVvFOxsKxCK9q_.TrQ-1785241875.3071089-1.0.1.1-Tib27.qtzXbg_qQWS47BsCBVza1VbrPPXJwWSO_loshjfDSqyj8.hQMNnjkc6MvWRNy1Q12h8p5b0S9qSKZJOC4i.oKMW1KZGlMeH35Ag_eUVTiPBOpk3DDEnVMu2cZj; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=c1Oz9Xr4bLCLfcAq%2FIrlyYQ3%2BfejzXSjI5SbLyMWdwIKLSoLuc5CwK8A5YumeYsA89O%2BPaNEuqV2IKyOHS9Vjd8ttfo%2BM1bgHV7jViXQju5NY8L3rX73WbQ%3D\"}]}","age":"46830","accept-ranges":"bytes","access-control-expose-headers":"*","x-robots-tag":"noindex","x-jsr-backend":"modules","content-length":"562","cf-ray":"a223e658ad217db6-LAX","alt-svc":"h3=\":443\"; ma=86400","content-type":"text/typescript"},"url":"https://jsr.io/@std/assert/0.224.0/assert.ts","time":1785241875}