import { invert } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/object/index.js";
Composes a new record with all keys and values inverted.
This function is effectively as
Object.fromEntries(Object.entries(record).map(([key, value]) => [value, key]))
.
Examples
Example 1
Example 1
import { invert } from "@ayonli/jsext/object";
const obj = { foo: "Hello", bar: "World" };
const result = invert(obj);
console.log(result); // { Hello: "foo", World: "bar" }