Skip to content
/ swob Public

Swap object key abd value with correct typing

License

Notifications You must be signed in to change notification settings

tylim88/swob

Repository files navigation

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

About

Swap object key abd value with correct typing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published