caseless
    Overview
    Documentation
    Tutorials
    Insights
    Code
    Dependencies
    Contributors
    Jobs

caseless

Caseless object set/get/has, very useful when working with HTTP headers.

0.12.0  •  Updated 2 years ago  •  by request  •  Apache License 2.0

Caseless – wrap an object to set and get property with caseless semantics but also preserve caseing.

This library is incredibly useful when working with HTTP headers. It allows you to get/set/check for headers in a caseless manner while also preserving the caseing of headers the first time they are set.

Usage

var headers = {}
  , c = caseless(headers)
  ;
c.set('a-Header', 'asdf')
c.get('a-header') === 'asdf'

has(key)

Has takes a name and if it finds a matching header will return that header name with the preserved caseing it was set with.

c.has('a-header') === 'a-Header'

set(key, value[, clobber=true])

Set is fairly straight forward except that if the header exists and clobber is disabled it will add ','+value to the existing header.

c.set('a-Header', 'fdas')
c.set('a-HEADER', 'more', false)
c.get('a-header') === 'fdsa,more'

swap(key)

Swaps the casing of a header with the new one that is passed in.

var headers = {}
  , c = caseless(headers)
  ;
c.set('a-Header', 'fdas')
c.swap('a-HEADER')
c.has('a-header') === 'a-HEADER'
headers === {'a-HEADER': 'fdas'}

Popularity

Weekly Downloads
12.6M
Stars
78

Maintenance

Development

Last ver 3 years ago
Created 7 years ago
Last commit 2 years ago
1 month between commits

Technology

Node version: 6.9.2
0 unpacked

Compliance

Apache License 2.0
OSI Approved
0 vulnerabilities

Contributors

9 contributors
Mikeal Rogers
Maintainer, 35 commits, 7 merges, 1 PRs
Works at Protocol Labs
James Nylen
Maintainer, 4 commits, 2 merges
Adrian Gschwend
4 commits, 2 PRs
Works at Zazuko GmbH
Peter Ajtai
1 commits, 1 PRs
Works at https://www.soliddigital.com/
Mark Bradshaw
1 commits, 1 PRs
Eirik S. Morland
1 commits, 1 PRs

Dependencies

Tags

headers
http
caseless
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.