seyfert/src/api/utils/utils.ts
Marcos Susaña bd951397a2
feat: Reduce dependencies (#221)
* feat: add support for new Discord application emojis features

* feat: add support for new Discord application emojis features

* feat: applications emojis routes

* chore: switch typings provider

* fix: unnecesary type

* feat: magic bytes

* chore: move api-types

* chore: ?

* fix: omg npm

* chore: apply formatting

* fix: for fast merge

---------

Co-authored-by: Tony Supremacy <165050835+VanStk@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-21 22:58:40 -04:00

20 lines
727 B
TypeScript

import type { Snowflake } from '../../types';
/**
* Calculates the default avatar index for a given user id.
*
* @param userId - The user id to calculate the default avatar index for
*/
export function calculateUserDefaultAvatarIndex(userId: Snowflake, discriminator: string) {
return discriminator === '0' ? Number(BigInt(userId) >> 22n) % 6 : Number.parseInt(discriminator) % 5;
}
/**
* Verifies that a value is a buffer-like object.
*
* @param value - The value to check
*/
export function isBufferLike(value: unknown): value is ArrayBuffer | Buffer | Uint8Array | Uint8ClampedArray {
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
}