swob
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

swob

npm GitHub tylim88

🐤 swap object key and value and return accurate type.

🥰 0 dependency.

⛲️ Out of box typescript support.

🦺 Tested.

Installation

npm i swob

Usage

🎵 Usage

import swob from 'swob'

const swapped = swob({ a: '1' as const, b: '2' as const, c: '3' as const })

console.log(swapped) // {'1': 'a','2': 'b','3': 'c'}

type swapped = typeof swapped // {'1': 'a','2': 'b','3': 'c'}

Important, you must use const assertion as shown in above example!

return new object, does not modify original object

Package Sidebar

Install

npm i swob

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.31 kB

Total Files

9

Last publish

Collaborators

  • tylim