UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

15 lines (14 loc) 342 B
export function invert(object) { const _ = (obj, trans) => { const result = {}; for (const entry of Object.entries(obj)) { const [key, value] = trans(entry); result[key] = value; } return result; }; return _(object, ([key, value]) => [ value, key, ]); }