mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
fix: Unexpected TypeError in GatewayManager.requestMembers (#4197)
* fix: Unexpected TypeError in `GatewayManager.requestMembers` debug message closes #4196 * refactor: prefer JSON.stringify replacer parameter when serializing * Order functions in utils.ts
This commit is contained in:
@@ -14,3 +14,14 @@ export async function delay(ms: number): Promise<void> {
|
||||
export function hasProperty<T extends {}, Y extends PropertyKey = string>(obj: T, prop: Y): obj is T & Record<Y, unknown> {
|
||||
return obj.hasOwnProperty(prop)
|
||||
}
|
||||
|
||||
/** Convert `JSON.stringify`-unserializable record values for debugging purposes. */
|
||||
export function jsonSafeReplacer(_key: string, value: unknown): unknown {
|
||||
switch (typeof value) {
|
||||
case 'bigint':
|
||||
// Bigints are unserializable by `JSON.stringify`.
|
||||
return String(value)
|
||||
default: // Any other unhandled type that isn't supposed to require conversion.
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user