Responselike

responselike

response-like object for mocking HTTP response stream.

responselike returns a streamable response object similar to a HTTP response stream. Useful for formatting cached responses so they can be consumed by code expecting a real response.

Get it: npm install responselike

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const Response = require('responselike');

const response = new Response(200, { foo: 'bar' }, Buffer.from('Hi!'), 'https://example.com');

response.statusCode;
// 200
response.headers;
// { foo: 'bar' }
response.body;
// <Buffer 48 69 21>
response.url;
// 'https://example.com'

response.pipe(process.stdout);
// Hi!

GIF FTW!

responselike

Suggest a module

Comments