The `methods` package, currently at version 1.1.2, provides a normalized, lower-cased array of HTTP method names supported by the Node.js runtime. This module serves as a robust alternative or enhancement to Node.js core's `http.METHODS`, especially for environments requiring broader compatibility. Its key differentiators include automatically lower-casing all method names for consistent usage and offering a fallback list for older Node.js versions (0.10 and below) that predate the `http.METHODS` export. Furthermore, it's designed to function seamlessly with browser bundling tools like Browserify without inadvertently pulling in the larger `http` shim module, making it lightweight for client-side use cases where a list of standard HTTP verbs is needed. The package is very stable, with infrequent updates, reflecting its foundational role and mature status within the Node.js ecosystem, particularly as a utility for web frameworks like Express.
npm install methodsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the `methods` array and iterate through the supported HTTP verbs. It also shows a simple function to check if a specific HTTP method is included in the list.
Use `const methods = require('methods')` in CommonJS contexts. For ESM, use `import methods from 'methods'` and rely on bundler configurations, or consider dynamic import: `const { default: methods } = await import('methods')`.Access the methods directly from the array (e.g., `methods.includes('get')`) or iterate over the array (`methods.forEach(...)`).Remove the function call parentheses: `const allMethods = methods;`
Use a default import for ESM: `import methods from 'methods'`, or the CommonJS `require`: `const methods = require('methods')`.No dependency data recorded yet.