swob
v1.0.0
Published
Swap object key and value and return accurate type
Downloads
1
Readme
swob
🐤 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