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

/**
 * Creates a new object by excluding the specified keys from the provided object.
 *
 * @template T The type of the object.
 * @template K The type of the keys to omit.
 *
 * @param obj The object to omit keys from.
 * @param keys The keys to omit from the object.
 *
 * @returns A new object with the specified keys omitted.
 *
 * @example Basic usage
 * ```ts
 * import { omit } from "@std/collections/omit";
 * import { assertEquals } from "@std/assert/assert-equals";
 *
 * const obj = { a: 5, b: 6, c: 7, d: 8 };
 * const omitted = omit(obj, ["a", "c"]);
 *
 * assertEquals(omitted, { b: 6, d: 8 });
 * ```
 */
export function omit<T extends object, K extends keyof T>(
  obj: Readonly<T>,
  keys: readonly K[],
): Omit<T, K> {
  const excludes = new Set(keys);
  return Object.fromEntries(
    Object.entries(obj).filter(([k, _]) => !excludes.has(k as K)),
  ) as Omit<T, K>;
}

// denoCacheMetadata={"headers":{"vary":"Origin","etag":"\"b2a2cf580913a53f96bb3f1302efc34a\"","access-control-allow-origin":"*","cross-origin-resource-policy":"cross-origin","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=SfXAeATxq1VDWEZu%2F9tzTupjP0fnKuubKoSKV6hMtCxBMTLJpLqoHAMEiG%2FAZnG0ZJroLkuNCOIrflNwcsE%2BWkLKtKIWY2%2FYZthCmpfeyD8i%2FiPPUvRhU1w%3D\"}]}","x-content-type-options":"nosniff","content-length":"1002","cf-ray":"a223e6564f257db6-LAX","date":"Tue, 28 Jul 2026 12:31:15 GMT","access-control-expose-headers":"*","x-robots-tag":"noindex","set-cookie":"__cf_bm=M9VxSdcKUmBf81wlOkyUrs5KzC_i9Cj..JAwhaWtTjc-1785241874.961384-1.0.1.1-_zCAzusnU3abLjBVExh7A4G8NZXAPv7IUNyXceDLcbAKhmRBhUhM.8bcZ5DkPO33MmjZqewVpw1D2XKaCUjzWozeeuGL93mOmv1Yg8zFpB8ZRu6e311ApIm3dFAXpW87; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","content-type":"text/typescript","cache-control":"public, max-age=31536000, immutable","x-jsr-backend":"modules","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","alt-svc":"h3=\":443\"; ma=86400","server":"cloudflare","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';"},"url":"https://jsr.io/@std/collections/0.224.2/omit.ts","time":1785241875}