uuid-bigint
v1.0.0
Published
UUID to BigInt conversion and vise versa
Downloads
2
Readme
JavaScript UUID to Bigint conversion and vice versa
This library provides utilities for converting UUIDs (Universally Unique Identifiers) to BigInt values and vice versa. This conversion is particularly useful in memory-intensive applications where reducing memory usage is critical.
Why Use BigInt Conversion?
UUIDs are 128-bit identifiers typically represented as 36-character strings (including hyphens). Converting these to BigInt values offers significant memory savings. Feel free to investigate test, you can see 30x memory consumption reducing.
Examples
Converts a UUID string to a BigInt value.
import { uuidToBigint } from "uuid-bigint";
const uuid = "123e4567-e89b-12d3-a456-426614174000";
const bigIntValue = uuidToBigint(uuid);
console.log(bigIntValue); // 24249434048109030647017182301789831168nConverts a BigInt value back to a UUID string.
import { bigintToUuid } from "uuid-bigint";
const bigIntValue = 24249434048109030647017182301789831168n;
const uuid = bigintToUuid(bigIntValue);
console.log(uuid); // "123e4567-e89b-12d3-a456-426614174000"