1 | interface BitFieldOptions {
|
2 | |
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | grow?: number;
|
12 | }
|
13 | export default class BitField {
|
14 | |
15 |
|
16 |
|
17 |
|
18 | private readonly grow;
|
19 |
|
20 | buffer: Uint8Array;
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | constructor(data?: number | Uint8Array, opts?: BitFieldOptions);
|
28 | /**
|
29 | * Get a particular bit.
|
30 | *
|
31 | * @param i Bit index to retrieve.
|
32 | * @returns A boolean indicating whether the `i`th bit is set.
|
33 | */
|
34 | get(i: number): boolean;
|
35 | /**
|
36 | * Set a particular bit.
|
37 | *
|
38 | * Will grow the underlying array if the bit is out of bounds and the `grow` option is set.
|
39 | *
|
40 | * @param i Bit index to set.
|
41 | * @param value Value to set the bit to. Defaults to `true`.
|
42 | */
|
43 | set(i: number, value?: boolean): void;
|
44 | /**
|
45 | * Loop through the bits in the bitfield.
|
46 | *
|
47 | * @param fn Function to be called with the bit value and index.
|
48 | * @param start Index of the first bit to look at.
|
49 | * @param end Index of the first bit that should no longer be considered.
|
50 | */
|
51 | forEach(fn: (bit: boolean, index: number) => void, start?: number, end?: number): void;
|
52 | }
|
53 | export {};
|
54 |
|
\ | No newline at end of file |