caseless helps to get/set/check specially for headers in a caseless manner while also preserving the caseing of headers the first time they are set.
Get it:npm install caseless
Sample usage:
12345678910111213141516171819202122232425262728
constc=require('caseless');letheaders={'a-header':'asdf','Content-Length':1000},c=caseless(headers);// Get setc.set('a-Header','asdf');c.get('a-header')==='asdf';// has checkc.has('a-header')==='a-Header';// set valuesc.set('a-Header','fdas')c.set('a-HEADER','more',false)c.get('a-header')==='fdsa,more'// delc.del('Content-length');// swapc.set('a-Header','fdas')c.swap('a-HEADER')c.has('a-header')==='a-HEADER'// headers === {'a-HEADER': 'fdas'}