chore: run format

This commit is contained in:
Vlad Frangu
2025-10-05 16:13:56 +03:00
parent 2a712d4909
commit 8dc1692d87
189 changed files with 3172 additions and 916 deletions

View File

@@ -80,8 +80,10 @@ export function Mixin<DestinationClass extends typeof Structure<{}>>(
// Special case for optimize function, we want to combine these
if (prop === OptimizeDataPropertyName) {
if (typeof descriptor.value !== 'function')
if (typeof descriptor.value !== 'function') {
throw new RangeError(`Expected ${prop} to be a function, received ${typeof descriptor.value} instead.`);
}
dataOptimizations.push(descriptor.value);
continue;
}

View File

@@ -107,7 +107,10 @@ export abstract class BitField<Flags extends string> {
total |= this.constructor.resolve(bit);
}
if (Object.isFrozen(this)) return new this.constructor(this.bitField | total);
if (Object.isFrozen(this)) {
return new this.constructor(this.bitField | total);
}
this.bitField |= total;
return this;
}
@@ -124,7 +127,10 @@ export abstract class BitField<Flags extends string> {
total |= this.constructor.resolve(bit);
}
if (Object.isFrozen(this)) return new this.constructor(this.bitField & ~total);
if (Object.isFrozen(this)) {
return new this.constructor(this.bitField & ~total);
}
this.bitField &= ~total;
return this;
}
@@ -138,7 +144,9 @@ export abstract class BitField<Flags extends string> {
public serialize(...hasParams: readonly unknown[]) {
const serialized: Partial<Record<keyof Flags, boolean>> = {};
for (const [flag, bit] of Object.entries(this.constructor.Flags)) {
if (Number.isNaN(Number(flag))) serialized[flag as keyof Flags] = this.has(bit as bigint | number, ...hasParams);
if (Number.isNaN(Number(flag))) {
serialized[flag as keyof Flags] = this.has(bit as bigint | number, ...hasParams);
}
}
return serialized;
@@ -174,7 +182,9 @@ export abstract class BitField<Flags extends string> {
public *[Symbol.iterator](...hasParams: unknown[]) {
for (const bitName of Object.keys(this.constructor.Flags)) {
if (Number.isNaN(Number(bitName)) && this.has(bitName as Flags, ...hasParams)) yield bitName as Flags;
if (Number.isNaN(Number(bitName)) && this.has(bitName as Flags, ...hasParams)) {
yield bitName as Flags;
}
}
}
@@ -186,16 +196,30 @@ export abstract class BitField<Flags extends string> {
*/
public static resolve<Flags extends string = string>(bit: BitFieldResolvable<Flags>): bigint {
const DefaultBit = this.DefaultBit;
if (typeof bit === 'bigint' && bit >= DefaultBit) return bit;
if (typeof bit === 'number' && BigInt(bit) >= DefaultBit) return BigInt(bit);
if (bit instanceof BitField) return bit.bitField;
if (typeof bit === 'bigint' && bit >= DefaultBit) {
return bit;
}
if (typeof bit === 'number' && BigInt(bit) >= DefaultBit) {
return BigInt(bit);
}
if (bit instanceof BitField) {
return bit.bitField;
}
if (Array.isArray(bit)) {
return bit.map((bit_) => this.resolve(bit_)).reduce((prev, bit_) => prev | bit_, DefaultBit);
}
if (typeof bit === 'string') {
if (!Number.isNaN(Number(bit))) return BigInt(bit);
if (bit in this.Flags) return this.Flags[bit as keyof typeof this.Flags];
if (!Number.isNaN(Number(bit))) {
return BigInt(bit);
}
if (bit in this.Flags) {
return this.Flags[bit as keyof typeof this.Flags];
}
}
throw new Error(`BitFieldInvalid: ${JSON.stringify(bit)}`);

View File

@@ -174,7 +174,10 @@ export class User<Omitted extends keyof APIUser | '' = ''> extends Structure<API
*/
public get hexAccentColor() {
const accentColor = this.accentColor;
if (typeof accentColor !== 'number') return accentColor;
if (typeof accentColor !== 'number') {
return accentColor;
}
return `#${accentColor.toString(16).padStart(6, '0')}`;
}
}