nsarrazin HF Staff commited on
Commit
8a3811e
·
unverified ·
1 Parent(s): 4480871

remove dead code (#1339)

Browse files
src/lib/utils/analytics.ts DELETED
@@ -1,39 +0,0 @@
1
- export interface GAEvent {
2
- hitType: "event";
3
- eventCategory: string;
4
- eventAction: string;
5
- eventLabel?: string;
6
- eventValue?: number;
7
- }
8
-
9
- // Send a Google Analytics event
10
- export function sendAnalyticsEvent({
11
- eventCategory,
12
- eventAction,
13
- eventLabel,
14
- eventValue,
15
- }: Omit<GAEvent, "hitType">): void {
16
- // Mandatory fields
17
- const event: GAEvent = {
18
- hitType: "event",
19
- eventCategory,
20
- eventAction,
21
- };
22
- // Optional fields
23
- if (eventLabel) {
24
- event.eventLabel = eventLabel;
25
- }
26
- if (eventValue) {
27
- event.eventValue = eventValue;
28
- }
29
-
30
- // @ts-expect-error typescript doesn't know gtag is on the window object
31
- if (!!window?.gtag && typeof window?.gtag === "function") {
32
- // @ts-expect-error typescript doesn't know gtag is on the window object
33
- window?.gtag("event", eventAction, {
34
- event_category: event.eventCategory,
35
- event_label: event.eventLabel,
36
- value: event.eventValue,
37
- });
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/lib/utils/concatUint8Arrays.ts DELETED
@@ -1,12 +0,0 @@
1
- import { sum } from "./sum";
2
-
3
- export function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array {
4
- const totalLength = sum(arrays.map((a) => a.length));
5
- const result = new Uint8Array(totalLength);
6
- let offset = 0;
7
- for (const array of arrays) {
8
- result.set(array, offset);
9
- offset += array.length;
10
- }
11
- return result;
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
src/lib/utils/loadClientCerts.ts DELETED
@@ -1,50 +0,0 @@
1
- import * as fs from "fs";
2
- import { setGlobalDispatcher, Agent } from "undici";
3
-
4
- /**
5
- * Load client certificates for mutual TLS authentication. This function must be called before any HTTP requests are made.
6
- * This is a global setting that affects all HTTP requests made by the application using the native fetch API.
7
- *
8
- * @param clientCertPath Path to client certificate
9
- * @param clientKeyPath Path to client key
10
- * @param caCertPath Path to CA certificate [optional]
11
- * @param clientKeyPassword Password for client key [optional]
12
- * @param rejectUnauthorized Reject unauthorized certificates.
13
- * Only use for testing/development, not recommended in production environments [optional]
14
- *
15
- * @returns void
16
- *
17
- * @example
18
- * ```typescript
19
- * loadClientCertificates("cert.pem", "key.pem", "ca.pem", "password", false);
20
- * ```
21
- *
22
- * @see
23
- * [Undici Agent](https://undici.nodejs.org/#/docs/api/Agent)
24
- * @see
25
- * [Undici Dispatcher](https://undici.nodejs.org/#/docs/api/Dispatcher)
26
- * @see
27
- * [NodeJS Native Fetch API](https://nodejs.org/docs/latest-v19.x/api/globals.html#fetch)
28
- */
29
- export function loadClientCertificates(
30
- clientCertPath: string,
31
- clientKeyPath: string,
32
- caCertPath?: string,
33
- clientKeyPassword?: string,
34
- rejectUnauthorized?: boolean
35
- ): void {
36
- const clientCert = fs.readFileSync(clientCertPath);
37
- const clientKey = fs.readFileSync(clientKeyPath);
38
- const caCert = caCertPath ? fs.readFileSync(caCertPath) : undefined;
39
- const agent = new Agent({
40
- connect: {
41
- cert: clientCert,
42
- key: clientKey,
43
- ca: caCert,
44
- passphrase: clientKeyPassword,
45
- rejectUnauthorized,
46
- },
47
- });
48
-
49
- setGlobalDispatcher(agent);
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/lib/utils/streamToAsyncIterable.ts DELETED
@@ -1,15 +0,0 @@
1
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of#iterating_over_async_generators
2
- export async function* streamToAsyncIterable(
3
- stream: ReadableStream<Uint8Array>
4
- ): AsyncIterableIterator<Uint8Array> {
5
- const reader = stream.getReader();
6
- try {
7
- while (true) {
8
- const { done, value } = await reader.read();
9
- if (done) return;
10
- yield value;
11
- }
12
- } finally {
13
- reader.releaseLock();
14
- }
15
- }