trender-client
Version:
Official Trender client API
92 lines (91 loc) • 3.15 kB
TypeScript
export default BitField;
/**
* Data structure to easily work with bits.
*/
declare class BitField {
/**
* Data that can be resolved to give a bitfield. This can be:
* * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS})
* * A string bit number
* * An instance of BitField
* * An Array of BitFieldResolvable
* @typedef {number|string|bigint|BitField|BitFieldResolvable[]} BitFieldResolvable
*/
/**
* Resolves bitfields to their numeric form.
* @param {BitFieldResolvable} [bit] bit(s) to resolve
* @returns {number|bigint}
*/
static resolve(bit?: any): number | bigint;
/**
* @param {BitFieldResolvable} [bits=this.constructor.defaultBit] Bit(s) to read from
*/
constructor(bits?: any);
/**
* Bitfield of the packed bits
* @type {number|bigint}
*/
bitfield: number | bigint;
/**
* Checks whether the bitfield has a bit, or any of multiple bits.
* @param {BitFieldResolvable} bit Bit(s) to check for
* @returns {boolean}
*/
any(bit: any): boolean;
/**
* Checks if this bitfield equals another
* @param {BitFieldResolvable} bit Bit(s) to check for
* @returns {boolean}
*/
equals(bit: any): boolean;
/**
* Checks whether the bitfield has a bit, or multiple bits.
* @param {BitFieldResolvable} bit Bit(s) to check for
* @returns {boolean}
*/
has(bit: any): boolean;
/**
* Gets all given bits that are missing from the bitfield.
* @param {BitFieldResolvable} bits Bit(s) to check for
* @param {...*} hasParams Additional parameters for the has method, if any
* @returns {string[]}
*/
missing(bits: any, ...hasParams: any[]): string[];
/**
* Freezes these bits, making them immutable.
* @returns {Readonly<BitField>}
*/
freeze(): Readonly<BitField>;
/**
* Adds bits to these ones.
* @param {...BitFieldResolvable} [bits] Bits to add
* @returns {BitField} These bits or new BitField if the instance is frozen.
*/
add(...bits?: any[] | undefined): BitField;
/**
* Removes bits from these.
* @param {...BitFieldResolvable} [bits] Bits to remove
* @returns {BitField} These bits or new BitField if the instance is frozen.
*/
remove(...bits?: any[] | undefined): BitField;
/**
* Gets an object mapping field names to a {@link boolean} indicating whether the
* bit is available.
* @param {...*} hasParams Additional parameters for the has method, if any
* @returns {Object}
*/
serialize(...hasParams: any[]): Object;
/**
* Gets an {@link Array} of bitfield names based on the bits available.
* @param {...*} hasParams Additional parameters for the has method, if any
* @returns {string[]}
*/
toArray(...hasParams: any[]): string[];
toJSON(): string | number;
valueOf(): number | bigint;
[Symbol.iterator](): Generator<string, void, undefined>;
}
declare namespace BitField {
const FLAGS: Object;
const defaultBit: number | bigint;
}