File size: 1,674 Bytes
5641073
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { IDisposable } from './disposable';
/**
 * The maximum number of bytes that can be read from the hash.
 *
 * Calculated out 2^64-1, since `Xn` syntax (for `Xn ** Yn`) requires TS
 * targeting esnext/es2020 which includes features that Node 10 doesn't
 * yet supported.
 */
export declare const maxHashBytes: bigint;
/**
 * The HashReader is a type returned from any of the hash functions. It can
 */
export interface IHashReader<T> extends IDisposable {
    /**
     * Returns the position of the reader in the hash. Can be written to to seek.
     */
    position: bigint;
    /**
     * Reads data from the hash into the target array. The target will always
     * be completely filled with data.
     */
    readInto(target: Uint8Array): void;
    /**
     * Reads and returns the given number of bytes from the hash, advancing
     * the position of the reader.
     */
    read(bytes: number): T;
}
/**
 * Underlying native or wasm module code backing the reader.
 * @hidden
 */
export interface IInternalReader {
    free?(): void;
    fill(target: Uint8Array): void;
    set_position(position: bigint): void;
}
/**
 * Base hash reader implementation.
 */
export declare abstract class BaseHashReader<T extends Uint8Array> implements IHashReader<T> {
    private reader;
    private pos;
    get position(): bigint;
    set position(value: bigint);
    constructor(reader: IInternalReader);
    /**
     * @inheritdoc
     */
    readInto(target: Uint8Array): void;
    /**
     * @inheritdoc
     */
    read(bytes: number): T;
    /**
     * @inheritdoc
     */
    dispose(): void;
    protected abstract alloc(bytes: number): T;
    private boundsCheck;
}