|
1 | 1 | /// <reference types="node" /> |
| 2 | +import type { Readable as ReadableStream } from "node:stream"; |
2 | 3 |
|
3 | | -interface CreateTorrentOptions { |
| 4 | +export type CreateTorrentCallback = (err: Error | null, torrent?: Buffer) => void; |
| 5 | + |
| 6 | +export interface CreateTorrentOptions { |
4 | 7 | // name of the torrent (default = basename of `path`, or 1st file's name) |
5 | 8 | name?: string | undefined; |
6 | 9 | // free-form textual comments of the author |
7 | 10 | comment?: string | undefined; |
8 | 11 | // name and version of program used to create torrent |
9 | 12 | createdBy?: string | undefined; |
10 | 13 | // creation time in UNIX epoch format (default = now) |
11 | | - creationDate?: number | undefined; |
| 14 | + creationDate?: number | Date | undefined; |
12 | 15 | // is this a private .torrent? (default = false) |
13 | 16 | private?: boolean | undefined; |
14 | 17 | // force a custom piece length (number of bytes) |
15 | 18 | pieceLength?: number | undefined; |
| 19 | + maxPieceLength?: number; |
16 | 20 | // custom trackers (array of arrays of strings) (see [bep12](http://www.bittorrent.org/beps/bep_0012.html)) |
17 | 21 | announceList?: string[][] | undefined; |
18 | 22 | // web seed urls (see [bep19](http://www.bittorrent.org/beps/bep_0019.html)) |
19 | 23 | urlList?: string[] | undefined; |
20 | 24 | // add non-standard info dict entries, e.g. info.source, a convention for cross-seeding |
21 | | - info?: Record<string, string> | undefined; |
| 25 | + info?: Record<string, unknown>; |
22 | 26 | // called with the number of bytes hashed and estimated total size after every piece |
23 | | - onProgress?(hashedLength: number, estimatedTorrentLength: number): void; |
| 27 | + onProgress?: (hashedLength: number, estimatedTorrentLength: number) => void; |
24 | 28 | } |
25 | 29 |
|
26 | | -declare function createTorrent( |
27 | | - input: |
28 | | - | string |
29 | | - | string[] |
30 | | - | File |
31 | | - | File[] |
32 | | - | FileList |
33 | | - | Buffer |
34 | | - | Buffer[] |
35 | | - | NodeJS.ReadableStream |
36 | | - | NodeJS.ReadableStream[], |
37 | | - cb: (err: Error | null, torrent: Buffer) => any, |
38 | | -): void; |
| 30 | +export type TorrentInput = |
| 31 | + | string |
| 32 | + | File |
| 33 | + | FileList |
| 34 | + | Buffer |
| 35 | + | ReadableStream |
| 36 | + | string[] |
| 37 | + | File[] |
| 38 | + | Buffer[] |
| 39 | + | ReadableStream[]; |
| 40 | + |
| 41 | +declare function createTorrent(input: TorrentInput, opts: CreateTorrentOptions, cb: CreateTorrentCallback): void; |
| 42 | +declare function createTorrent(input: TorrentInput, cb: CreateTorrentCallback): void; |
39 | 43 |
|
40 | | -declare function createTorrent( |
41 | | - input: |
42 | | - | string |
43 | | - | string[] |
44 | | - | File |
45 | | - | File[] |
46 | | - | FileList |
47 | | - | Buffer |
48 | | - | Buffer[] |
49 | | - | NodeJS.ReadableStream |
50 | | - | NodeJS.ReadableStream[], |
51 | | - opts: CreateTorrentOptions, |
52 | | - cb: (err: Error | null, torrent: Buffer) => any, |
53 | | -): void; |
| 44 | +declare const announceList: string[][]; |
| 45 | +declare function isJunkPath(path: string): boolean; |
54 | 46 |
|
55 | | -export = createTorrent; |
| 47 | +export default createTorrent; |
| 48 | +export { announceList, isJunkPath }; |
0 commit comments