@bnidev/js-utils
    Preparing search index...

    Function invert

    • Creates a new object with keys and values swapped.

      Type Parameters

      • T extends Record<string, string | number>

        The type of the source object.

      Parameters

      • obj: T

        The object to invert.

      Returns Record<string, string>

      A new object with keys and values swapped.

      // ES Module
      import { invert } from '@bnidev/js-utils'

      // CommonJS
      const { invert } = require('@bnidev/js-utils')
      const obj = { a: '1', b: '2', c: '3' }
      const result = invert(obj)
      // result: { '1': 'a', '2': 'b', '3': 'c' }