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 | get length(): number;
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | constructor(data?: number | Uint8Array, options?: BitFieldOptions);
|
30 | /**
|
31 | * Get a particular bit.
|
32 | *
|
33 | * @param bitIndex Bit index to retrieve.
|
34 | * @returns A boolean indicating whether the `i`th bit is set.
|
35 | */
|
36 | get(bitIndex: number): boolean;
|
37 | /**
|
38 | * Set a particular bit.
|
39 | *
|
40 | * Will grow the underlying array if the bit is out of bounds and the `grow` option is set.
|
41 | *
|
42 | * @param bitIndex Bit index to set.
|
43 | * @param value Value to set the bit to. Defaults to `true`.
|
44 | */
|
45 | set(bitIndex: number, value?: boolean): void;
|
46 | /**
|
47 | * Sets a value or an array of values.
|
48 | *
|
49 | * @param array An array of booleans to set.
|
50 | * @param offset The bit offset at which the values are to be written.
|
51 | */
|
52 | setAll(array: ArrayLike<boolean>, offset?: number): void;
|
53 | /**
|
54 | * Loop through the bits in the bitfield.
|
55 | *
|
56 | * @param callbackfn Function to be called with the bit value and index.
|
57 | * @param start Index of the first bit to look at.
|
58 | * @param end Index of the first bit that should no longer be considered.
|
59 | */
|
60 | forEach(callbackfn: (bit: boolean, index: number) => void, start?: number, end?: number): void;
|
61 | /**
|
62 | * Check if all bits in the Bitfield are unset.
|
63 | *
|
64 | * @returns A boolean indicating whether all bits are unset.
|
65 | */
|
66 | isEmpty(): boolean;
|
67 | }
|
68 | export {};
|
69 |
|
\ | No newline at end of file |