What is @types/caseless?
@types/caseless provides TypeScript type definitions for the 'caseless' npm package, which allows for case-insensitive operations on HTTP headers.
What are @types/caseless's main functionalities?
Set a header
This feature allows you to set a header in a case-insensitive manner. The 'set' method ensures that the header name is stored in a consistent case.
const caseless = require('caseless');
const headers = caseless();
headers.set('Content-Type', 'application/json');
Get a header
This feature allows you to retrieve a header value in a case-insensitive manner. The 'get' method will return the value regardless of the case of the input header name.
const caseless = require('caseless');
const headers = caseless();
headers.set('Content-Type', 'application/json');
const contentType = headers.get('content-type');
Check if a header exists
This feature allows you to check if a header exists in a case-insensitive manner. The 'has' method returns a boolean indicating the presence of the header.
const caseless = require('caseless');
const headers = caseless();
headers.set('Content-Type', 'application/json');
const hasContentType = headers.has('content-type');
Delete a header
This feature allows you to delete a header in a case-insensitive manner. The 'del' method removes the header regardless of the case of the input header name.
const caseless = require('caseless');
const headers = caseless();
headers.set('Content-Type', 'application/json');
headers.del('content-type');
Other packages similar to @types/caseless
http-headers
The 'http-headers' package provides a similar functionality for managing HTTP headers in a case-insensitive manner. It offers methods to get, set, and delete headers, but it is more focused on parsing and formatting HTTP headers.
header-case-normalizer
The 'header-case-normalizer' package focuses on normalizing the case of HTTP headers. It ensures that headers are stored in a consistent case format, similar to 'caseless', but it does not provide as many utility methods for managing headers.
node-fetch
While 'node-fetch' is primarily a library for making HTTP requests, it includes built-in support for case-insensitive headers. It provides methods to set, get, and delete headers in a case-insensitive manner, similar to 'caseless'.
Installation
npm install --save @types/caseless
Summary
This package contains type definitions for caseless (https://github.com/mikeal/caseless).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/caseless.
type KeyType = string;
type ValueType = any;
type RawDict = object;
declare function caseless(dict?: RawDict): caseless.Caseless;
declare namespace caseless {
function httpify(resp: object, headers: RawDict): Caseless;
interface Caseless {
set(name: KeyType, value: ValueType, clobber?: boolean): KeyType | false;
set(dict: RawDict): void;
has(name: KeyType): KeyType | false;
get(name: KeyType): ValueType | undefined;
swap(name: KeyType): void;
del(name: KeyType): boolean;
}
interface Httpified {
headers: RawDict;
setHeader(name: KeyType, value: ValueType, clobber?: boolean): KeyType | false;
setHeader(dict: RawDict): void;
hasHeader(name: KeyType): KeyType | false;
getHeader(name: KeyType): ValueType | undefined;
removeHeader(name: KeyType): boolean;
}
}
export = caseless;
Additional Details
- Last updated: Mon, 06 Nov 2023 22:41:05 GMT
- Dependencies: none
Credits
These definitions were written by downace, Matt R. Wilson, and Emily Klassen.