summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
commit953ddd82e48dd206cef5ac94456549aed13b3ad5 (patch)
tree8f003106ee2e7f422e5a22d2ee04d0db302e66c0 /includes/external/addressbook/node_modules/@szmarczak/http-timer/dist
parent62a9199846b0c07c03218703b33e8385764f42d9 (diff)
downloadpluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.gz
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.bz2
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.zip
Updated 30 files and deleted 2976 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/@szmarczak/http-timer/dist')
-rw-r--r--includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.d.ts32
-rw-r--r--includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.js106
2 files changed, 0 insertions, 138 deletions
diff --git a/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.d.ts b/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.d.ts
deleted file mode 100644
index cae5c24..0000000
--- a/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.d.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/// <reference types="node" />
-import type { ClientRequest, IncomingMessage } from 'http';
-export interface Timings {
- start: number;
- socket?: number;
- lookup?: number;
- connect?: number;
- secureConnect?: number;
- upload?: number;
- response?: number;
- end?: number;
- error?: number;
- abort?: number;
- phases: {
- wait?: number;
- dns?: number;
- tcp?: number;
- tls?: number;
- request?: number;
- firstByte?: number;
- download?: number;
- total?: number;
- };
-}
-export interface ClientRequestWithTimings extends ClientRequest {
- timings?: Timings;
-}
-export interface IncomingMessageWithTimings extends IncomingMessage {
- timings?: Timings;
-}
-declare const timer: (request: ClientRequestWithTimings) => Timings;
-export default timer;
diff --git a/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.js b/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.js
deleted file mode 100644
index 407014f..0000000
--- a/includes/external/addressbook/node_modules/@szmarczak/http-timer/dist/source/index.js
+++ /dev/null
@@ -1,106 +0,0 @@
-import { errorMonitor } from 'events';
-import { types } from 'util';
-import deferToConnect from 'defer-to-connect';
-const timer = (request) => {
- if (request.timings) {
- return request.timings;
- }
- const timings = {
- start: Date.now(),
- socket: undefined,
- lookup: undefined,
- connect: undefined,
- secureConnect: undefined,
- upload: undefined,
- response: undefined,
- end: undefined,
- error: undefined,
- abort: undefined,
- phases: {
- wait: undefined,
- dns: undefined,
- tcp: undefined,
- tls: undefined,
- request: undefined,
- firstByte: undefined,
- download: undefined,
- total: undefined,
- },
- };
- request.timings = timings;
- const handleError = (origin) => {
- origin.once(errorMonitor, () => {
- timings.error = Date.now();
- timings.phases.total = timings.error - timings.start;
- });
- };
- handleError(request);
- const onAbort = () => {
- timings.abort = Date.now();
- timings.phases.total = timings.abort - timings.start;
- };
- request.prependOnceListener('abort', onAbort);
- const onSocket = (socket) => {
- timings.socket = Date.now();
- timings.phases.wait = timings.socket - timings.start;
- if (types.isProxy(socket)) {
- return;
- }
- const lookupListener = () => {
- timings.lookup = Date.now();
- timings.phases.dns = timings.lookup - timings.socket;
- };
- socket.prependOnceListener('lookup', lookupListener);
- deferToConnect(socket, {
- connect: () => {
- timings.connect = Date.now();
- if (timings.lookup === undefined) {
- socket.removeListener('lookup', lookupListener);
- timings.lookup = timings.connect;
- timings.phases.dns = timings.lookup - timings.socket;
- }
- timings.phases.tcp = timings.connect - timings.lookup;
- },
- secureConnect: () => {
- timings.secureConnect = Date.now();
- timings.phases.tls = timings.secureConnect - timings.connect;
- },
- });
- };
- if (request.socket) {
- onSocket(request.socket);
- }
- else {
- request.prependOnceListener('socket', onSocket);
- }
- const onUpload = () => {
- timings.upload = Date.now();
- timings.phases.request = timings.upload - (timings.secureConnect ?? timings.connect);
- };
- if (request.writableFinished) {
- onUpload();
- }
- else {
- request.prependOnceListener('finish', onUpload);
- }
- request.prependOnceListener('response', (response) => {
- timings.response = Date.now();
- timings.phases.firstByte = timings.response - timings.upload;
- response.timings = timings;
- handleError(response);
- response.prependOnceListener('end', () => {
- request.off('abort', onAbort);
- response.off('aborted', onAbort);
- if (timings.phases.total) {
- // Aborted or errored
- return;
- }
- timings.end = Date.now();
- timings.phases.download = timings.end - timings.response;
- timings.phases.total = timings.end - timings.start;
- });
- response.prependOnceListener('aborted', onAbort);
- });
- return timings;
-};
-export default timer;