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

/**
 * Less than or equal to comparison
 *
 * This is equal to `compare(s0, s1) <= 0`.
 *
 * @example Usage
 * ```ts
 * import { parse, lessOrEqual } from "@std/semver";
 * import { assert, assertFalse } from "@std/assert";
 *
 * const s0 = parse("1.2.3");
 * const s1 = parse("1.2.4");
 * assert(lessOrEqual(s0, s1));
 * assertFalse(lessOrEqual(s1, s0));
 * assert(lessOrEqual(s0, s0));
 * ```
 *
 * @param s0 the first version to compare
 * @param s1 the second version to compare
 * @returns `true` if `s0` is less than or equal to `s1`, `false` otherwise
 */
export function lessOrEqual(s0: SemVer, s1: SemVer): boolean {
  return compare(s0, s1) <= 0;
}

// denoCacheMetadata={"headers":{"alt-svc":"h3=\":443\"; ma=86400","cf-cache-status":"HIT","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';","content-length":"855","age":"36703","cache-control":"public, max-age=31536000, immutable","cf-ray":"a223e657caa07db6-LAX","server":"cloudflare","cross-origin-resource-policy":"cross-origin","x-jsr-backend":"modules","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=0TcOKKqf9ViPl06FHTDPLQznT0GcX%2BBRLQoG8cxYYVkXhHp1EFdFcPKa7RFys1G01tzcWiqMblRASxxN%2BENCN%2FNfs3G1Kx48%2Blei%2BEklaXKo%2BNq8KGTIrhY%3D\"}]}","set-cookie":"__cf_bm=NwUdi0r5nSDOwIfjWeDrrSEphWLacFoysWTLUWjQiXE-1785241875.1745965-1.0.1.1-Rp.u51W0xlYTtr2hMbmfpcAaZvPgA.dKbmsUYXxZapljJbGILPv_F9ixyogkhHsMMJX.jWt9sS2gT4UvYxVtR0PFYCpKJSoFNgKXX.MrhaZHWYY4jo.IW741ttuMWre7; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","accept-ranges":"bytes","x-content-type-options":"nosniff","vary":"Origin","etag":"\"5fb6049be2d65e498941aae9723f1ed2\"","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","content-type":"text/typescript","access-control-allow-origin":"*","access-control-expose-headers":"*","x-robots-tag":"noindex","date":"Tue, 28 Jul 2026 12:31:15 GMT"},"url":"https://jsr.io/@std/semver/0.224.3/less_or_equal.ts","time":1785241875}