snowflakify
Version:
The most complete Snowflake ID generator in TypeScript
32 lines (31 loc) • 926 B
TypeScript
import FragmentBase from '../FragmentBase.js';
import { DestructuredFragment } from '../@types';
/**
* ProcessFragment class for process IDs.
* @public
*/
export default class ProcessFragment extends FragmentBase {
/**
* @param bits - The number of bits for the fragment.
* @param value - A persistent ID value to use for the fragment.
*
* Defaults to the current process ID if omitted.
*
* @throws `[VALUE_INVALID_TYPE]` If value is not a number.
* @throws `[VALUE_INVALID_RANGE]` If value is not within 0 and 2 ** bits - 1
*/
constructor(bits: number, value?: number);
getValue(): bigint;
destructure(snowflake: number | bigint | string): DestructuredFragment;
updateId(): void;
/**
* Returns the process ID.
*
* @remarks
* The value is masked by the maxValue to fit in the fragment's bits.
*
* @returns The process ID.
* @internal
*/
private getProcessId;
}