|
| 1 | +declare module 'tarparser' { |
| 2 | + /** |
| 3 | + * @typedef FileDescription |
| 4 | + * @property {string} name - The name of the file. |
| 5 | + * @property {"file"|"directory"} type - The type of the file, either "file" or "directory". |
| 6 | + * @property {number} size - The size of the file in bytes. |
| 7 | + * @property {Uint8Array} data - The binary data of the file content. |
| 8 | + * @property {string} text - A getter to decode and return the file content as a UTF-8 string. |
| 9 | + * @property {FileAttrs} attrs - file attributes |
| 10 | + */ |
| 11 | + /** |
| 12 | + * @typedef FileAttrs |
| 13 | + * @property {string} mode - The file permissions in octal format. |
| 14 | + * @property {number} uid - User ID of the file owner. |
| 15 | + * @property {number} gid - Group ID of the file owner. |
| 16 | + * @property {number} mtime - Last modification time in Unix time format. |
| 17 | + * @property {string} user - The username of the file owner. |
| 18 | + * @property {string} group - The group name of the file owner. |
| 19 | + */ |
| 20 | + /** |
| 21 | + * Parses a tar file from binary data and returns an array of FileDescription objects. |
| 22 | + * @param {ArrayBuffer|Uint8Array} data - The binary data of the tar file. |
| 23 | + * @returns {Promise<FileDescription[]>} - An array of FileDescription objects representing the parsed files in the tar archive. |
| 24 | + */ |
| 25 | + export function parseTar(data: ArrayBuffer | Uint8Array): Promise<FileDescription[]>; |
| 26 | + export type FileDescription = { |
| 27 | + /** |
| 28 | + * - The name of the file. |
| 29 | + */ |
| 30 | + name: string; |
| 31 | + /** |
| 32 | + * - The type of the file, either "file" or "directory". |
| 33 | + */ |
| 34 | + type: 'file' | 'directory'; |
| 35 | + /** |
| 36 | + * - The size of the file in bytes. |
| 37 | + */ |
| 38 | + size: number; |
| 39 | + /** |
| 40 | + * - The binary data of the file content. |
| 41 | + */ |
| 42 | + data: Uint8Array; |
| 43 | + /** |
| 44 | + * - A getter to decode and return the file content as a UTF-8 string. |
| 45 | + */ |
| 46 | + text: string; |
| 47 | + /** |
| 48 | + * - file attributes |
| 49 | + */ |
| 50 | + attrs: FileAttrs; |
| 51 | + }; |
| 52 | + export type FileAttrs = { |
| 53 | + /** |
| 54 | + * - The file permissions in octal format. |
| 55 | + */ |
| 56 | + mode: string; |
| 57 | + /** |
| 58 | + * - User ID of the file owner. |
| 59 | + */ |
| 60 | + uid: number; |
| 61 | + /** |
| 62 | + * - Group ID of the file owner. |
| 63 | + */ |
| 64 | + gid: number; |
| 65 | + /** |
| 66 | + * - Last modification time in Unix time format. |
| 67 | + */ |
| 68 | + mtime: number; |
| 69 | + /** |
| 70 | + * - The username of the file owner. |
| 71 | + */ |
| 72 | + user: string; |
| 73 | + /** |
| 74 | + * - The group name of the file owner. |
| 75 | + */ |
| 76 | + group: string; |
| 77 | + }; |
| 78 | +} |
0 commit comments