Responselike provides a streamable object designed to mimic a Node.js HTTP response stream (`http.IncomingMessage`). This utility is primarily used for mocking HTTP responses in testing scenarios or for reformatting cached data to be consumed by code expecting a standard HTTP response. The current stable version is 4.0.2. The package is actively maintained by Sindre Sorhus, with releases typically occurring as needed for bug fixes or Node.js version updates, as seen with the recent v4.0.0 and v4.0.1/v4.0.2 updates. Its key differentiator is its focus on accurately replicating the streamable nature and properties of a native HTTP response, making it suitable for integrations where stream-based consumption is expected, unlike simpler object mocks.
npm install responselikeVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating a mock HTTP response, accessing its properties, and piping its body as a stream.
Upgrade your Node.js environment to version 20 or greater. If unable to upgrade, use `responselike@3.x` for Node.js 14+ or `responselike@2.x` for older Node.js versions.
Migrate your codebase to use ESM `import` statements. Refer to Sindre Sorhus's 'pure ESM' gist for guidance on migrating projects. Ensure your `package.json` is configured correctly for ESM.
Refactor calls from `new Response(statusCode, headers, body, url)` to `new Response({ statusCode, headers, body, url })`.Be aware that accessing headers should use lowercase keys, e.g., `response.headers['content-type']` even if originally provided as `{'Content-Type': '...'}`.Use `import Response from 'responselike';` instead of `const Response = require('responselike');`. Ensure your project is set up for ESM, potentially by adding `"type": "module"` to your `package.json`.Ensure the `body` option is explicitly set to a `Buffer.from('your content')` when creating a new `Response` instance.Correct the import statement to `import Response from 'responselike';` (for ESM) or verify your CommonJS wrapper if using older Node.js versions.
No dependency data recorded yet.