This package, `http-response-status-code`, provides a lightweight and comprehensive utility for interacting with HTTP status codes, names, and descriptions. Currently at version 1.7.5, it offers a stable API for retrieving details, validating codes, and categorizing them into informational, success, redirection, client error, and server error groups. The library differentiates itself by providing a full suite of helper functions, such as `getStatusName`, `getStatusDescription`, `getNotFound`, and dedicated checks like `isInformationalCode` or `isClientErrorCode`, in addition to exposing all standard HTTP status codes as named exports. Its release cadence appears to be moderate, with minor updates focusing on feature additions like the "Toolset Overview" in 1.7.2 and continuous code hygiene improvements. It ships with TypeScript types, ensuring robust usage in modern JavaScript and TypeScript environments, making it a reliable choice for handling HTTP response logic.
npm install http-response-status-codeVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import and use various utilities to retrieve status codes, names, descriptions, and check code categories.
Ensure you are calling the correct function, e.g., `STATUS_CODES.getStatusName(STATUS_CODES.OK)` or `STATUS_CODES.getStatusCode('OK')`.Avoid `import STATUS_CODES from 'pkg'` as a default import is not provided, which will result in `undefined`.
Always use the exact upper-case string name as defined in HTTP standards, or refer to the library's `CODES` object for a definitive list.
Correct the function call to `STATUS_CODES.getStatusName` or `STATUS_CODES.getStatusCode`.
Change your import statement to `import { OK } from 'http-response-status-code';` for specific codes or `import * as STATUS_CODES from 'http-response-status-code';` to access all exports via `STATUS_CODES.OK`.No dependency data recorded yet.