summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/mimic-response
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/mimic-response
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/mimic-response')
-rw-r--r--includes/external/addressbook/node_modules/mimic-response/index.d.ts29
-rw-r--r--includes/external/addressbook/node_modules/mimic-response/index.js75
-rw-r--r--includes/external/addressbook/node_modules/mimic-response/license9
-rw-r--r--includes/external/addressbook/node_modules/mimic-response/package.json44
-rw-r--r--includes/external/addressbook/node_modules/mimic-response/readme.md78
5 files changed, 235 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/mimic-response/index.d.ts b/includes/external/addressbook/node_modules/mimic-response/index.d.ts
new file mode 100644
index 0000000..324613f
--- /dev/null
+++ b/includes/external/addressbook/node_modules/mimic-response/index.d.ts
@@ -0,0 +1,29 @@
+import {IncomingMessage} from 'node:http';
+
+/**
+Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
+
+Makes `toStream` include the properties from `fromStream`.
+
+@param fromStream - The stream to copy the properties from.
+@param toStream - The stream to copy the properties to.
+@return The same object as `toStream`.
+
+@example
+```
+import {PassThrough as PassThroughStream} from 'node:stream';
+import mimicResponse from 'mimic-response';
+
+const responseStream = getHttpResponseStream();
+const myStream = new PassThroughStream();
+
+mimicResponse(responseStream, myStream);
+
+console.log(myStream.statusCode);
+//=> 200
+```
+*/
+export default function mimicResponse<T extends NodeJS.ReadableStream>(
+ fromStream: IncomingMessage,
+ toStream: T,
+): T & IncomingMessage;
diff --git a/includes/external/addressbook/node_modules/mimic-response/index.js b/includes/external/addressbook/node_modules/mimic-response/index.js
new file mode 100644
index 0000000..a2e898f
--- /dev/null
+++ b/includes/external/addressbook/node_modules/mimic-response/index.js
@@ -0,0 +1,75 @@
+// We define these manually to ensure they're always copied
+// even if they would move up the prototype chain
+// https://nodejs.org/api/http.html#http_class_http_incomingmessage
+const knownProperties = [
+ 'aborted',
+ 'complete',
+ 'headers',
+ 'httpVersion',
+ 'httpVersionMinor',
+ 'httpVersionMajor',
+ 'method',
+ 'rawHeaders',
+ 'rawTrailers',
+ 'setTimeout',
+ 'socket',
+ 'statusCode',
+ 'statusMessage',
+ 'trailers',
+ 'url',
+];
+
+export default function mimicResponse(fromStream, toStream) {
+ if (toStream._readableState.autoDestroy) {
+ throw new Error('The second stream must have the `autoDestroy` option set to `false`');
+ }
+
+ const fromProperties = new Set([...Object.keys(fromStream), ...knownProperties]);
+
+ const properties = {};
+
+ for (const property of fromProperties) {
+ // Don't overwrite existing properties.
+ if (property in toStream) {
+ continue;
+ }
+
+ properties[property] = {
+ get() {
+ const value = fromStream[property];
+ const isFunction = typeof value === 'function';
+
+ return isFunction ? value.bind(fromStream) : value;
+ },
+ set(value) {
+ fromStream[property] = value;
+ },
+ enumerable: true,
+ configurable: false,
+ };
+ }
+
+ Object.defineProperties(toStream, properties);
+
+ fromStream.once('aborted', () => {
+ toStream.destroy();
+
+ toStream.emit('aborted');
+ });
+
+ fromStream.once('close', () => {
+ if (fromStream.complete) {
+ if (toStream.readable) {
+ toStream.once('end', () => {
+ toStream.emit('close');
+ });
+ } else {
+ toStream.emit('close');
+ }
+ } else {
+ toStream.emit('close');
+ }
+ });
+
+ return toStream;
+}
diff --git a/includes/external/addressbook/node_modules/mimic-response/license b/includes/external/addressbook/node_modules/mimic-response/license
new file mode 100644
index 0000000..fa7ceba
--- /dev/null
+++ b/includes/external/addressbook/node_modules/mimic-response/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
+
+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/mimic-response/package.json b/includes/external/addressbook/node_modules/mimic-response/package.json
new file mode 100644
index 0000000..bf5e8ca
--- /dev/null
+++ b/includes/external/addressbook/node_modules/mimic-response/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "mimic-response",
+ "version": "4.0.0",
+ "description": "Mimic a Node.js HTTP response stream",
+ "license": "MIT",
+ "repository": "sindresorhus/mimic-response",
+ "funding": "https://github.com/sponsors/sindresorhus",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "https://sindresorhus.com"
+ },
+ "type": "module",
+ "exports": "./index.js",
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.d.ts",
+ "index.js"
+ ],
+ "keywords": [
+ "mimic",
+ "response",
+ "stream",
+ "http",
+ "https",
+ "request",
+ "get",
+ "core"
+ ],
+ "devDependencies": {
+ "@types/node": "^16.4.13",
+ "ava": "^3.15.0",
+ "create-test-server": "^3.0.1",
+ "p-event": "^4.2.0",
+ "pify": "^5.0.0",
+ "tsd": "^0.17.0",
+ "xo": "^0.44.0"
+ }
+}
diff --git a/includes/external/addressbook/node_modules/mimic-response/readme.md b/includes/external/addressbook/node_modules/mimic-response/readme.md
new file mode 100644
index 0000000..09f1299
--- /dev/null
+++ b/includes/external/addressbook/node_modules/mimic-response/readme.md
@@ -0,0 +1,78 @@
+# mimic-response
+
+> Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
+
+## Install
+
+```
+$ npm install mimic-response
+```
+
+## Usage
+
+```js
+import {PassThrough as PassThroughStream} from 'node:stream';
+import mimicResponse from 'mimic-response';
+
+const responseStream = getHttpResponseStream();
+const myStream = new PassThroughStream();
+
+mimicResponse(responseStream, myStream);
+
+console.log(myStream.statusCode);
+//=> 200
+```
+
+## API
+
+### mimicResponse(from, to)
+
+**Note #1:** The `from.destroy(error)` function is not proxied. You have to call it manually:
+
+```js
+import {PassThrough as PassThroughStream} from 'node:stream';
+import mimicResponse from 'mimic-response';
+
+const responseStream = getHttpResponseStream();
+
+const myStream = new PassThroughStream({
+ destroy(error, callback) {
+ responseStream.destroy();
+
+ callback(error);
+ }
+});
+
+myStream.destroy();
+```
+
+Please note that `myStream` and `responseStream` never throw. The error is passed to the request instead.
+
+#### from
+
+Type: `Stream`
+
+[Node.js HTTP response stream.](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
+
+#### to
+
+Type: `Stream`
+
+Any stream.
+
+## Related
+
+- [mimic-fn](https://github.com/sindresorhus/mimic-fn) - Make a function mimic another one
+- [clone-response](https://github.com/lukechilds/clone-response) - Clone a Node.js response stream
+
+---
+
+<div align="center">
+ <b>
+ <a href="https://tidelift.com/subscription/pkg/npm-mimic-response?utm_source=npm-mimic-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+ </b>
+ <br>
+ <sub>
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+ </sub>
+</div>