cross-seed 7.0.0-1 → 7.0.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Result.d.ts +27 -0
- package/dist/Result.js +64 -0
- package/dist/Result.js.map +1 -0
- package/dist/action.d.ts +34 -0
- package/dist/action.js +694 -0
- package/dist/action.js.map +1 -0
- package/dist/arr.d.ts +31 -0
- package/dist/arr.js +267 -0
- package/dist/arr.js.map +1 -0
- package/dist/auth.d.ts +3 -0
- package/dist/auth.js +28 -0
- package/dist/auth.js.map +1 -0
- package/dist/clients/Deluge.d.ts +153 -0
- package/dist/clients/Deluge.js +698 -0
- package/dist/clients/Deluge.js.map +1 -0
- package/dist/clients/QBittorrent.d.ts +218 -0
- package/dist/clients/QBittorrent.js +785 -0
- package/dist/clients/QBittorrent.js.map +1 -0
- package/dist/clients/RTorrent.d.ts +43 -0
- package/dist/clients/RTorrent.js +657 -0
- package/dist/clients/RTorrent.js.map +1 -0
- package/dist/clients/TorrentClient.d.ts +108 -0
- package/dist/clients/TorrentClient.js +341 -0
- package/dist/clients/TorrentClient.js.map +1 -0
- package/dist/clients/Transmission.d.ts +43 -0
- package/dist/clients/Transmission.js +404 -0
- package/dist/clients/Transmission.js.map +1 -0
- package/dist/cmd.d.ts +2 -0
- package/dist/cmd.js +128 -0
- package/dist/cmd.js.map +1 -0
- package/dist/configSchema.d.ts +1 -0
- package/dist/configSchema.js +2 -0
- package/dist/configSchema.js.map +1 -0
- package/dist/configuration.d.ts +63 -0
- package/dist/configuration.js +321 -0
- package/dist/configuration.js.map +1 -0
- package/dist/constants.d.ts +108 -0
- package/dist/constants.js +251 -0
- package/dist/constants.js.map +1 -0
- package/dist/dataFiles.d.ts +8 -0
- package/dist/dataFiles.js +223 -0
- package/dist/dataFiles.js.map +1 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +216 -0
- package/dist/db.js.map +1 -0
- package/dist/dbConfig.d.ts +4 -0
- package/dist/dbConfig.js +67 -0
- package/dist/dbConfig.js.map +1 -0
- package/dist/decide.d.ts +25 -0
- package/dist/decide.js +553 -0
- package/dist/decide.js.map +1 -0
- package/dist/diff.d.ts +1 -0
- package/dist/diff.js +24 -0
- package/dist/diff.js.map +1 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/indexers.d.ts +105 -0
- package/dist/indexers.js +248 -0
- package/dist/indexers.js.map +1 -0
- package/dist/inject.d.ts +2 -0
- package/dist/inject.js +594 -0
- package/dist/inject.js.map +1 -0
- package/dist/jobs.d.ts +29 -0
- package/dist/jobs.js +151 -0
- package/dist/jobs.js.map +1 -0
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +157 -0
- package/dist/logger.js.map +1 -0
- package/dist/migrations/00-initialSchema.d.ts +9 -0
- package/dist/migrations/00-initialSchema.js +30 -0
- package/dist/migrations/00-initialSchema.js.map +1 -0
- package/dist/migrations/01-jobs.d.ts +9 -0
- package/dist/migrations/01-jobs.js +12 -0
- package/dist/migrations/01-jobs.js.map +1 -0
- package/dist/migrations/02-timestamps.d.ts +9 -0
- package/dist/migrations/02-timestamps.js +21 -0
- package/dist/migrations/02-timestamps.js.map +1 -0
- package/dist/migrations/03-rateLimits.d.ts +9 -0
- package/dist/migrations/03-rateLimits.js +14 -0
- package/dist/migrations/03-rateLimits.js.map +1 -0
- package/dist/migrations/04-auth.d.ts +9 -0
- package/dist/migrations/04-auth.js +13 -0
- package/dist/migrations/04-auth.js.map +1 -0
- package/dist/migrations/05-caps.d.ts +9 -0
- package/dist/migrations/05-caps.js +16 -0
- package/dist/migrations/05-caps.js.map +1 -0
- package/dist/migrations/06-uniqueDecisions.d.ts +9 -0
- package/dist/migrations/06-uniqueDecisions.js +29 -0
- package/dist/migrations/06-uniqueDecisions.js.map +1 -0
- package/dist/migrations/07-limits.d.ts +9 -0
- package/dist/migrations/07-limits.js +12 -0
- package/dist/migrations/07-limits.js.map +1 -0
- package/dist/migrations/08-rss.d.ts +9 -0
- package/dist/migrations/08-rss.js +15 -0
- package/dist/migrations/08-rss.js.map +1 -0
- package/dist/migrations/09-clientAndDataSearchees.d.ts +9 -0
- package/dist/migrations/09-clientAndDataSearchees.js +34 -0
- package/dist/migrations/09-clientAndDataSearchees.js.map +1 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.d.ts +9 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.js +18 -0
- package/dist/migrations/10-indexerNameAudioBookCaps.js.map +1 -0
- package/dist/migrations/11-trackers.d.ts +9 -0
- package/dist/migrations/11-trackers.js +38 -0
- package/dist/migrations/11-trackers.js.map +1 -0
- package/dist/migrations/12-user-auth.d.ts +9 -0
- package/dist/migrations/12-user-auth.js +22 -0
- package/dist/migrations/12-user-auth.js.map +1 -0
- package/dist/migrations/13-settings.d.ts +9 -0
- package/dist/migrations/13-settings.js +23 -0
- package/dist/migrations/13-settings.js.map +1 -0
- package/dist/migrations/14-indexer-enabled-flag.d.ts +9 -0
- package/dist/migrations/14-indexer-enabled-flag.js +12 -0
- package/dist/migrations/14-indexer-enabled-flag.js.map +1 -0
- package/dist/migrations/15-remove-url-unique-constraint.d.ts +9 -0
- package/dist/migrations/15-remove-url-unique-constraint.js +14 -0
- package/dist/migrations/15-remove-url-unique-constraint.js.map +1 -0
- package/dist/migrations/16-prune-inactive-indexers.d.ts +9 -0
- package/dist/migrations/16-prune-inactive-indexers.js +17 -0
- package/dist/migrations/16-prune-inactive-indexers.js.map +1 -0
- package/dist/migrations/migrations.d.ts +13 -0
- package/dist/migrations/migrations.js +41 -0
- package/dist/migrations/migrations.js.map +1 -0
- package/dist/parseTorrent.d.ts +53 -0
- package/dist/parseTorrent.js +128 -0
- package/dist/parseTorrent.js.map +1 -0
- package/dist/pipeline.d.ts +41 -0
- package/dist/pipeline.js +574 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/preFilter.d.ts +25 -0
- package/dist/preFilter.js +250 -0
- package/dist/preFilter.js.map +1 -0
- package/dist/problems/linking.d.ts +2 -0
- package/dist/problems/linking.js +80 -0
- package/dist/problems/linking.js.map +1 -0
- package/dist/problems/path.d.ts +22 -0
- package/dist/problems/path.js +96 -0
- package/dist/problems/path.js.map +1 -0
- package/dist/problems.d.ts +13 -0
- package/dist/problems.js +48 -0
- package/dist/problems.js.map +1 -0
- package/dist/pushNotifier.d.ts +19 -0
- package/dist/pushNotifier.js +137 -0
- package/dist/pushNotifier.js.map +1 -0
- package/dist/routes/baseApi.d.ts +2 -0
- package/dist/routes/baseApi.js +354 -0
- package/dist/routes/baseApi.js.map +1 -0
- package/dist/routes/indexerApi.d.ts +6 -0
- package/dist/routes/indexerApi.js +165 -0
- package/dist/routes/indexerApi.js.map +1 -0
- package/dist/routes/staticFrontendPlugin.d.ts +4 -0
- package/dist/routes/staticFrontendPlugin.js +63 -0
- package/dist/routes/staticFrontendPlugin.js.map +1 -0
- package/dist/runtimeConfig.d.ts +6 -0
- package/dist/runtimeConfig.js +27 -0
- package/dist/runtimeConfig.js.map +1 -0
- package/dist/searchee.d.ts +108 -0
- package/dist/searchee.js +689 -0
- package/dist/searchee.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +65 -0
- package/dist/server.js.map +1 -0
- package/dist/services/indexerService.d.ts +96 -0
- package/dist/services/indexerService.js +287 -0
- package/dist/services/indexerService.js.map +1 -0
- package/dist/sessionCookies.d.ts +5 -0
- package/dist/sessionCookies.js +27 -0
- package/dist/sessionCookies.js.map +1 -0
- package/dist/startup.d.ts +25 -0
- package/dist/startup.js +157 -0
- package/dist/startup.js.map +1 -0
- package/dist/torrent.d.ts +69 -0
- package/dist/torrent.js +641 -0
- package/dist/torrent.js.map +1 -0
- package/dist/torznab.d.ts +60 -0
- package/dist/torznab.js +711 -0
- package/dist/torznab.js.map +1 -0
- package/dist/trpc/fastifyAdapter.d.ts +2 -0
- package/dist/trpc/fastifyAdapter.js +9 -0
- package/dist/trpc/fastifyAdapter.js.map +1 -0
- package/dist/trpc/index.d.ts +49 -0
- package/dist/trpc/index.js +53 -0
- package/dist/trpc/index.js.map +1 -0
- package/dist/trpc/routers/auth.d.ts +43 -0
- package/dist/trpc/routers/auth.js +116 -0
- package/dist/trpc/routers/auth.js.map +1 -0
- package/dist/trpc/routers/clients.d.ts +21 -0
- package/dist/trpc/routers/clients.js +65 -0
- package/dist/trpc/routers/clients.js.map +1 -0
- package/dist/trpc/routers/health.d.ts +14 -0
- package/dist/trpc/routers/health.js +20 -0
- package/dist/trpc/routers/health.js.map +1 -0
- package/dist/trpc/routers/index.d.ts +391 -0
- package/dist/trpc/routers/index.js +23 -0
- package/dist/trpc/routers/index.js.map +1 -0
- package/dist/trpc/routers/indexers.d.ts +75 -0
- package/dist/trpc/routers/indexers.js +79 -0
- package/dist/trpc/routers/indexers.js.map +1 -0
- package/dist/trpc/routers/jobs.d.ts +33 -0
- package/dist/trpc/routers/jobs.js +84 -0
- package/dist/trpc/routers/jobs.js.map +1 -0
- package/dist/trpc/routers/logs.d.ts +27 -0
- package/dist/trpc/routers/logs.js +91 -0
- package/dist/trpc/routers/logs.js.map +1 -0
- package/dist/trpc/routers/searchees.d.ts +51 -0
- package/dist/trpc/routers/searchees.js +156 -0
- package/dist/trpc/routers/searchees.js.map +1 -0
- package/dist/trpc/routers/settings.d.ts +83 -0
- package/dist/trpc/routers/settings.js +92 -0
- package/dist/trpc/routers/settings.js.map +1 -0
- package/dist/trpc/routers/stats.d.ts +42 -0
- package/dist/trpc/routers/stats.js +102 -0
- package/dist/trpc/routers/stats.js.map +1 -0
- package/dist/userAuth.d.ts +21 -0
- package/dist/userAuth.js +86 -0
- package/dist/userAuth.js.map +1 -0
- package/dist/utils/authUtils.d.ts +10 -0
- package/dist/utils/authUtils.js +24 -0
- package/dist/utils/authUtils.js.map +1 -0
- package/dist/utils/logWatcher.d.ts +28 -0
- package/dist/utils/logWatcher.js +218 -0
- package/dist/utils/logWatcher.js.map +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/object.js +4 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils.d.ts +175 -0
- package/dist/utils.js +660 -0
- package/dist/utils.js.map +1 -0
- package/package.json +17 -58
- package/LICENSE +0 -201
- package/README.md +0 -33
- package/dist/webui/assets/FieldInfo-Bxj_j8SJ.js +0 -1
- package/dist/webui/assets/Page-C3rteCZt.js +0 -1
- package/dist/webui/assets/array-field-DVSC6nHP.js +0 -1
- package/dist/webui/assets/badge-DTZMtS0e.js +0 -1
- package/dist/webui/assets/check-Bu3ldi63.js +0 -1
- package/dist/webui/assets/chevron-down-CRy8M0kJ.js +0 -1
- package/dist/webui/assets/clients-CW8oEZoQ.js +0 -1
- package/dist/webui/assets/connect-YBNsnjWT.js +0 -1
- package/dist/webui/assets/debug-mz8-WYZj.js +0 -1
- package/dist/webui/assets/directories-BSK28RgR.js +0 -1
- package/dist/webui/assets/duration-field-C6xoSlJg.js +0 -1
- package/dist/webui/assets/general-lJJxZhH7.js +0 -1
- package/dist/webui/assets/health-CXbsVrie.js +0 -1
- package/dist/webui/assets/index-Bi48hI2z.js +0 -54
- package/dist/webui/assets/index-C-Ul7GNg.css +0 -1
- package/dist/webui/assets/index-C2cH1Gst.js +0 -1
- package/dist/webui/assets/index-Cc5bDmJr.js +0 -1
- package/dist/webui/assets/jobs-CxmNab9w.js +0 -1
- package/dist/webui/assets/library-vaj2W8sE.js +0 -1
- package/dist/webui/assets/loader-circle-M0gu1gZ-.js +0 -1
- package/dist/webui/assets/logs-Cu9RyKS0.js +0 -1
- package/dist/webui/assets/search-2R5sIdT8.js +0 -1
- package/dist/webui/assets/select-field-BCqNLDrJ.js +0 -1
- package/dist/webui/assets/select-zHgqMzLj.js +0 -1
- package/dist/webui/assets/settings-CMYjpTbZ.js +0 -1
- package/dist/webui/assets/submit-button-BtcnyggQ.js +0 -1
- package/dist/webui/assets/switch-G0W3uJVN.js +0 -1
- package/dist/webui/assets/switch-field-IBd9ORNq.js +0 -1
- package/dist/webui/assets/table-DvgJU7Gh.js +0 -1
- package/dist/webui/assets/test-tube-BIwmoM45.js +0 -1
- package/dist/webui/assets/text-field-DruSbGhy.js +0 -1
- package/dist/webui/assets/time-BSMZjmyW.js +0 -1
- package/dist/webui/assets/trackers-D-OpAe63.js +0 -7
- package/dist/webui/assets/use-form-validation-context-BkAfWAh0.js +0 -1
- package/dist/webui/assets/use-settings-form-submit-CDRh-E9U.js +0 -2
- package/dist/webui/assets/useQuery-A4Hv_4uX.js +0 -1
- package/dist/webui/index.html +0 -13
- package/node_modules/@cross-seed/shared/dist/configSchema.d.ts +0 -261
- package/node_modules/@cross-seed/shared/dist/configSchema.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/configSchema.js +0 -53
- package/node_modules/@cross-seed/shared/dist/configSchema.js.map +0 -1
- package/node_modules/@cross-seed/shared/dist/constants.d.ts +0 -122
- package/node_modules/@cross-seed/shared/dist/constants.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/constants.js +0 -127
- package/node_modules/@cross-seed/shared/dist/constants.js.map +0 -1
- package/node_modules/@cross-seed/shared/dist/tsconfig.tsbuildinfo +0 -1
- package/node_modules/@cross-seed/shared/dist/utils.d.ts +0 -6
- package/node_modules/@cross-seed/shared/dist/utils.d.ts.map +0 -1
- package/node_modules/@cross-seed/shared/dist/utils.js +0 -9
- package/node_modules/@cross-seed/shared/dist/utils.js.map +0 -1
- package/node_modules/@cross-seed/shared/package.json +0 -22
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { ChalkInstance } from "chalk";
|
|
2
|
+
import type { Stats } from "fs";
|
|
3
|
+
import { Result } from "./Result.js";
|
|
4
|
+
import { File, Searchee } from "./searchee.js";
|
|
5
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
6
|
+
type Truthy<T> = T extends false | "" | 0 | null | undefined ? never : T;
|
|
7
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
8
|
+
[P in K]-?: T[P];
|
|
9
|
+
};
|
|
10
|
+
export type WithUndefined<T, K extends keyof T> = Omit<T, K> & {
|
|
11
|
+
[P in K]: undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function isTruthy<T>(value: T): value is Truthy<T>;
|
|
14
|
+
export declare function exists(srcPath: string): Promise<boolean>;
|
|
15
|
+
export declare function notExists(srcPath: string): Promise<boolean>;
|
|
16
|
+
export type DirVerificationFailureReason = "missing" | "not-directory" | "unreadable" | "unwritable";
|
|
17
|
+
export type DirVerificationResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
stats: Stats;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
reason: DirVerificationFailureReason;
|
|
23
|
+
error?: unknown;
|
|
24
|
+
};
|
|
25
|
+
export declare function verifyDir(srcDir: string, testSrcName: string, permissions: number): Promise<DirVerificationResult>;
|
|
26
|
+
export declare function isChildPath(childPath: string, parentDirs: string[]): boolean;
|
|
27
|
+
export declare function countDirEntriesRec(dirs: string[], maxDataDepth: number): Promise<number>;
|
|
28
|
+
export declare function hasExt(files: File[], exts: string[]): boolean;
|
|
29
|
+
export declare function stripExtension(filename: string): string;
|
|
30
|
+
export declare function filesWithExt(files: File[], exts: string[]): File[];
|
|
31
|
+
export declare function findAFileWithExt(dir: string, exts: string[]): Promise<string | null>;
|
|
32
|
+
export declare function nMsAgo(n: number): number;
|
|
33
|
+
export declare function wait(n: number): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Yield control to the event loop allowing all pending tasks to be processed
|
|
36
|
+
* regardless of the current phase.
|
|
37
|
+
* @param n Optional number of milliseconds to wait before yielding.
|
|
38
|
+
*/
|
|
39
|
+
export declare function yieldToEventLoop(n?: number): Promise<void>;
|
|
40
|
+
export declare function time<R>(cb: () => Promise<R>, times: number[]): Promise<R>;
|
|
41
|
+
export declare function humanReadableDate(timestamp: number): string;
|
|
42
|
+
export declare function humanReadableSize(bytes: number, options?: {
|
|
43
|
+
binary: boolean;
|
|
44
|
+
}): string;
|
|
45
|
+
export declare function getLogString(searchee: Searchee, color?: ChalkInstance): string;
|
|
46
|
+
export declare function formatAsList(strings: string[], options: {
|
|
47
|
+
sort: boolean;
|
|
48
|
+
style?: Intl.ListFormatStyle;
|
|
49
|
+
type?: Intl.ListFormatType;
|
|
50
|
+
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* This cannot be done at the log level because of too many false positives.
|
|
53
|
+
* The caller will need to extract the infoHash from their specific syntax.
|
|
54
|
+
* @param infoHash The infoHash to sanitize
|
|
55
|
+
*/
|
|
56
|
+
export declare function sanitizeInfoHash(infoHash: string): string;
|
|
57
|
+
export declare function areMediaTitlesSimilar(a: string, b: string): boolean;
|
|
58
|
+
export declare function cleanseSeparators(str: string): string;
|
|
59
|
+
export declare function cleanTitle(title: string): string;
|
|
60
|
+
export declare function reformatTitleForSearching(name: string): string;
|
|
61
|
+
export declare function createKeyTitle(title: string): string | null;
|
|
62
|
+
export declare function isBadTitle(title: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Generates possible anime search queries from a given name.
|
|
65
|
+
* Only use if getMediaType returns anime as it's conditional on a few factors.
|
|
66
|
+
* @param stem The name without extension to generate queries from.
|
|
67
|
+
* @returns An array of possible search queries.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getAnimeQueries(stem: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Generates possible video search queries from a given name.
|
|
72
|
+
* Only use if getMediaType returns video as it's conditional on a few factors.
|
|
73
|
+
* @param stem The name without extension to generate queries from.
|
|
74
|
+
* @returns An array of possible search queries.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getVideoQueries(stem: string): string[];
|
|
77
|
+
export declare function stripMetaFromName(name: string): string;
|
|
78
|
+
export declare function sanitizeUrl(url: string | URL): string;
|
|
79
|
+
export declare function getApikey(url: string): string | null;
|
|
80
|
+
export declare function extractCredentialsFromUrl(url: string, basePath?: string): Result<{
|
|
81
|
+
username: string;
|
|
82
|
+
password: string;
|
|
83
|
+
href: string;
|
|
84
|
+
}, "invalid URL">;
|
|
85
|
+
export declare const tap: (fn: any) => (value: any) => any;
|
|
86
|
+
export declare function fallback<T>(...args: T[]): T | undefined;
|
|
87
|
+
export declare function findFallback<T, U>(arr: T[], items: U[], cb: (e: T, item: U) => boolean): T | undefined;
|
|
88
|
+
export declare function inBatches<T>(items: T[], cb: (batch: T[]) => Promise<void>, options?: {
|
|
89
|
+
batchSize: number;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
export declare function fromBatches<T, R>(items: T[], cb: (batch: T[]) => Promise<R[]>, options?: {
|
|
92
|
+
batchSize: number;
|
|
93
|
+
}): Promise<R[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Makes comparators for `Array.prototype.sort`.
|
|
96
|
+
* Second getter will be used if the first is a tie, etc.
|
|
97
|
+
* Booleans are treated as 0 and 1,
|
|
98
|
+
* Ascending by default, use - or ! for descending.
|
|
99
|
+
* @param getters
|
|
100
|
+
*/
|
|
101
|
+
export declare function comparing<T>(...getters: ((e: T) => number | boolean)[]): (a: T, b: T) => 0 | 1 | -1;
|
|
102
|
+
export declare function filterAsync<T>(arr: T[], predicate: (e: T) => Promise<boolean>): Promise<T[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Filters an array asynchronously in batches, yielding to the event loop
|
|
105
|
+
* between batches to avoid blocking the event loop for too long.
|
|
106
|
+
* @param arr The array to filter.
|
|
107
|
+
* @param predicate The asynchronous predicate function to test each element.
|
|
108
|
+
* @param options.batchSize The size of each batch to process.
|
|
109
|
+
* @returns A promise that resolves to an array of elements that satisfy the predicate.
|
|
110
|
+
*/
|
|
111
|
+
export declare function filterAsyncYield<T>(arr: T[], predicate: (e: T) => Promise<boolean>, options?: {
|
|
112
|
+
batchSize: number;
|
|
113
|
+
}): Promise<T[]>;
|
|
114
|
+
export declare function mapAsync<T, R>(arr: T[], cb: (e: T) => Promise<R>): Promise<R[]>;
|
|
115
|
+
export declare function flatMapAsync<T, R>(arr: T[], cb: (e: T) => Promise<R[]>): Promise<R[]>;
|
|
116
|
+
export declare function reduceAsync<T, R>(arr: T[], cb: (acc: R, cur: T, index: number, arr: T[]) => Promise<R>, initialValue: R): Promise<R>;
|
|
117
|
+
export declare function findAsync<T>(it: Iterable<T>, cb: (e: T) => Promise<boolean>): Promise<T | undefined>;
|
|
118
|
+
export declare function someAsync<T>(it: Iterable<T>, cb: (e: T) => Promise<boolean>): Promise<boolean>;
|
|
119
|
+
export declare function everyAsync<T>(it: Iterable<T>, cb: (e: T) => Promise<boolean>): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Given multiple async iterables, this function will merge/interleave
|
|
122
|
+
* them all into one iterable, yielding on a first-come, first-serve basis.
|
|
123
|
+
* https://stackoverflow.com/questions/50585456/how-can-i-interleave-merge-async-iterables
|
|
124
|
+
*/
|
|
125
|
+
export declare function combineAsyncIterables<T>(asyncIterables: AsyncIterable<T>[]): AsyncGenerator<T>;
|
|
126
|
+
export declare function capitalizeFirstLetter(string: string): string;
|
|
127
|
+
/**
|
|
128
|
+
* Replaces the last occurrence of a GLOBAL regex match in a string
|
|
129
|
+
* @param str The string to replace the last occurrence in
|
|
130
|
+
* @param globalRegExp The regex to match (must be global)
|
|
131
|
+
* @param newStr The string to replace the last occurrence with
|
|
132
|
+
*/
|
|
133
|
+
export declare function replaceLastOccurrence(str: string, globalRegExp: RegExp, newStr: string): string;
|
|
134
|
+
export declare function escapeUnescapedQuotesInJsonValues(jsonStr: string): string;
|
|
135
|
+
export declare function extractInt(str: string): number;
|
|
136
|
+
export declare function getPathParts(pathStr: string, dirnameFunc?: (path: string) => string): string[];
|
|
137
|
+
export declare enum Mutex {
|
|
138
|
+
INDEX_TORRENTS_AND_DATA_DIRS = "INDEX_TORRENTS_AND_DATA_DIRS",
|
|
139
|
+
CHECK_JOBS = "CHECK_JOBS",
|
|
140
|
+
CREATE_ALL_SEARCHEES = "CREATE_ALL_SEARCHEES",
|
|
141
|
+
GUID_INFO_HASH_MAP = "GUID_INFO_HASH_MAP",
|
|
142
|
+
CLIENT_INJECTION = "CLIENT_INJECTION"
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Executes a callback function within a mutex for the given name.
|
|
146
|
+
* @param name The name of the mutex to create/use.
|
|
147
|
+
* @param options.useQueue If false, concurrent calls will share the pending result.
|
|
148
|
+
* @param cb The callback to execute.
|
|
149
|
+
* @returns The result of the callback.
|
|
150
|
+
*/
|
|
151
|
+
export declare function withMutex<T>(name: Mutex, options: {
|
|
152
|
+
useQueue: boolean;
|
|
153
|
+
}, cb: () => Promise<T>): Promise<T>;
|
|
154
|
+
/**
|
|
155
|
+
* An async safe semaphore implementation that preserves FIFO order.
|
|
156
|
+
* It uses an id for release to allow multiple releases (e.g try/finally with early releases).
|
|
157
|
+
* @param options.permits The number of concurrent permits.
|
|
158
|
+
* @param options.lifetimeMs Maximum lifetime of an acquire before automatic release.
|
|
159
|
+
*/
|
|
160
|
+
export declare class AsyncSemaphore {
|
|
161
|
+
private permits;
|
|
162
|
+
private lifetimeMs?;
|
|
163
|
+
private acquired;
|
|
164
|
+
private timers;
|
|
165
|
+
private waiting;
|
|
166
|
+
private counter;
|
|
167
|
+
private getNextId;
|
|
168
|
+
constructor(options: {
|
|
169
|
+
permits: number;
|
|
170
|
+
lifetimeMs?: number;
|
|
171
|
+
});
|
|
172
|
+
acquire(): Promise<number>;
|
|
173
|
+
release(id: number): void;
|
|
174
|
+
}
|
|
175
|
+
export {};
|