Sha256: d3dd6a98537a07a7ad526487bc891f1de18b50cd1f2e21ce4e592f314cb80806
Contents?: true
Size: 861 Bytes
Versions: 24
Compression:
Stored size: 861 Bytes
Contents
import {Readable as ReadableStream} from 'node:stream'; import lowercaseKeys from 'lowercase-keys'; export default class Response extends ReadableStream { statusCode; headers; body; url; constructor({statusCode, headers, body, url}) { if (typeof statusCode !== 'number') { throw new TypeError('Argument `statusCode` should be a number'); } if (typeof headers !== 'object') { throw new TypeError('Argument `headers` should be an object'); } if (!(body instanceof Uint8Array)) { throw new TypeError('Argument `body` should be a buffer'); } if (typeof url !== 'string') { throw new TypeError('Argument `url` should be a string'); } super({ read() { this.push(body); this.push(null); }, }); this.statusCode = statusCode; this.headers = lowercaseKeys(headers); this.body = body; this.url = url; } }
Version data entries
24 entries across 24 versions & 1 rubygems