Caseless is a JavaScript utility library designed to simplify interaction with objects, particularly HTTP headers, by providing caseless property access while preserving the original casing of the first-set key. This allows developers to retrieve or check for properties like 'Content-Type' using 'content-type' without explicit case manipulation. The current stable version is 0.12.0, indicating a mature, focused API that has likely been stable for some time, rather than undergoing rapid, frequent updates. Its primary differentiator is the unique combination of caseless lookup with the preservation of the original key casing, which is critical for scenarios where the exact string representation of a header might matter for display or specific protocol interpretations, even if its semantic meaning is case-insensitive. The library wraps a standard JavaScript object, adding a thin layer of caseless semantics without mutating the underlying data structure in unexpected ways.
npm install caselessVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize caseless with a plain object, set and get properties using caseless access, check for property existence while preserving original casing, and showcases the `clobber` option for appending values to existing properties.
Always explicitly define the `clobber` parameter in `set(key, value, clobber)` if you require a specific behavior regarding overwriting or appending values, especially when dealing with multi-valued HTTP headers.
Ensure you use the return value of `caseless(myObject)` (e.g., `const c = caseless(myObject)`) for all caseless operations. The original `myObject` will be modified by calls to `c.set()`.
Use a default import (`import caseless from 'caseless';`) for ESM or `const caseless = require('caseless');` for CommonJS, then call it as a function: `const c = caseless(myObject);`.Verify that `const c = caseless(myObject);` was successfully executed and that you are calling methods like `c.set()` or `c.get()` on the `c` variable.
No dependency data recorded yet.