summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/responselike
diff options
context:
space:
mode:
Diffstat (limited to 'includes/external/addressbook/node_modules/responselike')
-rw-r--r--includes/external/addressbook/node_modules/responselike/index.d.ts86
-rw-r--r--includes/external/addressbook/node_modules/responselike/index.js39
-rw-r--r--includes/external/addressbook/node_modules/responselike/license10
-rw-r--r--includes/external/addressbook/node_modules/responselike/package.json39
-rw-r--r--includes/external/addressbook/node_modules/responselike/readme.md75
5 files changed, 249 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/responselike/index.d.ts b/includes/external/addressbook/node_modules/responselike/index.d.ts
new file mode 100644
index 0000000..c99c4db
--- /dev/null
+++ b/includes/external/addressbook/node_modules/responselike/index.d.ts
@@ -0,0 +1,86 @@
+import {Buffer} from 'node:buffer';
+import {Readable as ReadableStream} from 'node:stream';
+
+export type Options = {
+ /**
+ The HTTP response status code.
+ */
+ readonly statusCode: number;
+
+ /**
+ The HTTP headers object.
+
+ Keys are in lowercase.
+ */
+ readonly headers: Record<string, string>;
+
+ /**
+ The response body.
+
+ The contents will be streamable but is also exposed directly as `response.body`.
+ */
+ readonly body: Buffer;
+
+ /**
+ The request URL string.
+ */
+ readonly url: string;
+};
+
+/**
+Returns a streamable response object similar to a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
+
+@example
+```
+import Response from 'responselike';
+
+const response = new Response({
+ statusCode: 200,
+ headers: {
+ foo: 'bar'
+ },
+ body: Buffer.from('Hi!'),
+ url: '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!'
+```
+*/
+export default class Response extends ReadableStream {
+ /**
+ The HTTP response status code.
+ */
+ readonly statusCode: number;
+
+ /**
+ The HTTP headers.
+
+ Keys will be automatically lowercased.
+ */
+ readonly headers: Record<string, string>;
+
+ /**
+ The response body.
+ */
+ readonly body: Buffer;
+
+ /**
+ The request URL string.
+ */
+ readonly url: string;
+
+ constructor(options?: Options);
+}
diff --git a/includes/external/addressbook/node_modules/responselike/index.js b/includes/external/addressbook/node_modules/responselike/index.js
new file mode 100644
index 0000000..6e2d40b
--- /dev/null
+++ b/includes/external/addressbook/node_modules/responselike/index.js
@@ -0,0 +1,39 @@
+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;
+ }
+}
diff --git a/includes/external/addressbook/node_modules/responselike/license b/includes/external/addressbook/node_modules/responselike/license
new file mode 100644
index 0000000..feeb70f
--- /dev/null
+++ b/includes/external/addressbook/node_modules/responselike/license
@@ -0,0 +1,10 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
+Copyright (c) Luke Childs <lukechilds123@gmail.com> (https://lukechilds.co.uk)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/external/addressbook/node_modules/responselike/package.json b/includes/external/addressbook/node_modules/responselike/package.json
new file mode 100644
index 0000000..c9d873a
--- /dev/null
+++ b/includes/external/addressbook/node_modules/responselike/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "responselike",
+ "version": "3.0.0",
+ "description": "A response-like object for mocking a Node.js HTTP response stream",
+ "license": "MIT",
+ "repository": "sindresorhus/responselike",
+ "funding": "https://github.com/sponsors/sindresorhus",
+ "author": "Luke Childs <lukechilds123@gmail.com> (https://lukechilds.co.uk)",
+ "type": "module",
+ "exports": "./index.js",
+ "engines": {
+ "node": ">=14.16"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "http",
+ "https",
+ "response",
+ "mock",
+ "test",
+ "request",
+ "responselike"
+ ],
+ "dependencies": {
+ "lowercase-keys": "^3.0.0"
+ },
+ "devDependencies": {
+ "ava": "^4.3.1",
+ "get-stream": "^6.0.1",
+ "tsd": "^0.22.0",
+ "xo": "^0.50.0"
+ }
+}
diff --git a/includes/external/addressbook/node_modules/responselike/readme.md b/includes/external/addressbook/node_modules/responselike/readme.md
new file mode 100644
index 0000000..51b5ecd
--- /dev/null
+++ b/includes/external/addressbook/node_modules/responselike/readme.md
@@ -0,0 +1,75 @@
+# responselike
+
+> A response-like object for mocking a Node.js HTTP response stream
+
+Returns a streamable response object similar to a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage). Useful for formatting cached responses so they can be consumed by code expecting a real response.
+
+## Install
+
+```sh
+npm install responselike
+```
+
+## Usage
+
+```js
+import Response from 'responselike';
+
+const response = new Response({
+ statusCode: 200,
+ headers: {
+ foo: 'bar'
+ },
+ body: Buffer.from('Hi!'),
+ url: '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!'
+```
+
+## API
+
+### new Response(options?)
+
+Returns a streamable response object similar to a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
+
+#### options
+
+Type: `object`
+
+##### statusCode
+
+Type: `number`
+
+The HTTP response status code.
+
+##### headers
+
+Type: `object`
+
+The HTTP headers. Keys will be automatically lowercased.
+
+##### body
+
+Type: `Buffer`
+
+The response body. The Buffer contents will be streamable but is also exposed directly as `response.body`.
+
+##### url
+
+Type: `string`
+
+The request URL string.