// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { isWindows } from "./_os.ts";
import { format as posixFormat } from "./posix/format.ts";
import { format as windowsFormat } from "./windows/format.ts";
import type { FormatInputPathObject } from "./_interface.ts";

/**
 * Generate a path from `FormatInputPathObject` object. It does the opposite
 * of `parse`.
 *
 * @param pathObject with path
 */
export function format(pathObject: FormatInputPathObject): string {
  return isWindows ? windowsFormat(pathObject) : posixFormat(pathObject);
}

// denoCacheMetadata={"headers":{"accept-ranges":"bytes","content-length":"615","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","set-cookie":"__cf_bm=NtHtXOZrQVz0BJRTVvq5s_2zoqX3TKVpIsVNQMeOIOs-1785241875.1400378-1.0.1.1-lKO.ZoB_4n025IoYZjs1Dm9aWoSiMLPtzNYa4UJ_UH4GTge93P8wQbEC5jitGNVxOPpRosoWzO1AvbB.g.brLrTvp.pzN_Pj5Ugatb9.9a3Rpqg5D6eHStGHALbvpIfv; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","server":"cloudflare","cf-ray":"a223e6579a147db6-LAX","access-control-allow-origin":"*","etag":"\"fb4877f17305573a28477f09893100d8\"","cf-cache-status":"HIT","vary":"Origin","x-jsr-backend":"modules","cross-origin-resource-policy":"cross-origin","cache-control":"public, max-age=31536000, immutable","x-content-type-options":"nosniff","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=vMv6mAqDYQu4jFMz4rJajpCpSxGYBhzbnXt5KyTZSwzq3T3KszT%2FHVM2yklBS%2FaO35Zq%2Fi%2BXScuJnl5RotjTsWUQiosfm8leNyxBqZlEFIWCSQfCcJ7mFaY%3D\"}]}","content-type":"text/typescript","access-control-expose-headers":"*","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","alt-svc":"h3=\":443\"; ma=86400","x-robots-tag":"noindex","age":"2671893"},"url":"https://jsr.io/@std/path/0.224.0/format.ts","time":1785241875}