UNPKG

1.65 kBTypeScriptView Raw
1import { WriteStream } from 'fs';
2import { Wrapper } from './wrapper';
3import { Repository } from './repository';
4import { Oid } from './oid';
5
6export class Blob {
7 /**
8 * @param repo - repository where to blob will be written
9 * @param buffer - data to be written into the blob
10 * @param len - length of the data
11 * @returns - return the id of the written blob
12 */
13 static createFromBuffer(repo: Repository, buffer: Buffer, len: number): Promise<Oid>;
14 /**
15 * @param repo - repository where the blob will be written. this repository can be bare or not
16 * @param path - file from which the blob will be created
17 */
18 static createFromDisk(repo: Repository, path: string): Promise<Oid>;
19 static createFromStream(repo: Repository, hintPath: string): Promise<WriteStream>;
20 /**
21 * @param repo - repository where the blob will be written. this repository cannot be bare
22 * @param relativePath - file from which the blob will be created, relative to the repository's working dir
23 * @returns - 0 or an error code
24 */
25 static createFromWorkdir(repo: Repository, relativePath: string): Promise<Oid>;
26 static filteredContent(blob: Blob, as_path: string, check_for_binary_data: number): Promise<Buffer>;
27 static lookup(repo: Repository, id: string | Oid | Blob): Promise<Blob>;
28 static lookupPrefix(repo: Repository, id: Oid, len: number): Promise<Blob>;
29
30 free(): void;
31 id(): Oid;
32 isBinary(): number;
33 owner(): Repository;
34 rawcontent(): Wrapper;
35 rawsize(): number;
36 content(): Buffer;
37 toString(): string;
38 filemode(): number;
39 dup(): Promise<Blob>;
40}