snowflakify
Version:
The most complete Snowflake ID generator in TypeScript
23 lines (22 loc) • 768 B
TypeScript
import FragmentBase from '../FragmentBase.js';
import { DestructuredFragment } from '../@types';
/**
* RandomFragment class for random IDs.
* @public
*/
export default class RandomFragment extends FragmentBase {
private readonly fn?;
/**
* @remarks
* When using a custom random function, please ensure it returns a positive number
* no greater than `2 ** bits - 1`.
*
* @param bits - The number of bits for the fragment.
* @param fn - Optional custom random function.
*
* @throws `[RND_FUNCTION_RETURN_TYPE]` If custom function does not return number or bigint.
*/
constructor(bits: number, fn?: (() => number | bigint) | undefined);
getValue(): bigint;
destructure(snowflake: number | bigint | string): DestructuredFragment;
}