# caseless

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

Latest version **0.12.0** (published 2017-01-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install caseless
pnpm add caseless
yarn add caseless
bun add caseless
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2017-01-26 |
| First published | 2013-09-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/caseless) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 94 |
| Author | Mikeal Rogers |
| Maintainers | mikeal, nylen, simov |
| Keywords | headers, http, caseless |

## Links

- npm: https://www.npmjs.com/package/caseless
- Repository: https://github.com/mikeal/caseless
- Homepage: https://github.com/mikeal/caseless#readme
- Issues: https://github.com/mikeal/caseless/issues
- npm.io page: https://npm.io/package/caseless

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.12.0 (latest) — 2017-01-26
- 0.11.0 — 2015-06-25
- 0.10.0 — 2015-03-13
- 0.9.0 — 2015-01-12
- 0.8.0 — 2014-11-21
- 0.7.0 — 2014-10-29
- 0.6.0 — 2014-08-11
- 0.5.0 — 2014-08-11
- 0.4.0 — 2014-07-24
- 0.3.0 — 2014-03-19
- 0.2.0 — 2014-03-19
- 0.1.0 — 2013-09-13

## README

## 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

```javascript
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.

```javascript
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.

```javascript
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.

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

---
_Source: https://npm.io/package/caseless · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
