// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/** Return type for {@linkcode invert}. */ /**
 * Composes a new record with all keys and values inverted.
 *
 * If the record contains duplicate values, subsequent values overwrite property
 * assignments of previous values. If the record contains values which aren't
 * {@linkcode PropertyKey}s their string representation is used as the key.
 *
 * @template T The type of the input record.
 *
 * @param record The record to invert.
 *
 * @returns A new record with all keys and values inverted.
 *
 * @example Basic usage
 * ```ts
 * import { invert } from "@std/collections/invert";
 * import { assertEquals } from "@std/assert/assert-equals";
 *
 * const record = { a: "x", b: "y", c: "z" };
 *
 * assertEquals(invert(record), { x: "a", y: "b", z: "c" });
 * ```
 */ export function invert(record) {
  return Object.fromEntries(Object.entries(record).map(([key, value])=>[
      value,
      key
    ]));
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHBzOi8vanNyLmlvL0BzdGQvY29sbGVjdGlvbnMvMC4yMjQuMi9pbnZlcnQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gQ29weXJpZ2h0IDIwMTgtMjAyNCB0aGUgRGVubyBhdXRob3JzLiBBbGwgcmlnaHRzIHJlc2VydmVkLiBNSVQgbGljZW5zZS5cbi8vIFRoaXMgbW9kdWxlIGlzIGJyb3dzZXIgY29tcGF0aWJsZS5cblxuLyoqIFJldHVybiB0eXBlIGZvciB7QGxpbmtjb2RlIGludmVydH0uICovXG5leHBvcnQgdHlwZSBJbnZlcnRSZXN1bHQ8VCBleHRlbmRzIFJlY29yZDxQcm9wZXJ0eUtleSwgUHJvcGVydHlLZXk+PiA9IHtcbiAgW1AgaW4ga2V5b2YgVCBhcyBUW1BdXTogUDtcbn07XG5cbi8qKlxuICogQ29tcG9zZXMgYSBuZXcgcmVjb3JkIHdpdGggYWxsIGtleXMgYW5kIHZhbHVlcyBpbnZlcnRlZC5cbiAqXG4gKiBJZiB0aGUgcmVjb3JkIGNvbnRhaW5zIGR1cGxpY2F0ZSB2YWx1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