numeric-uuid
Version:
A simple library to generate unique numeric UUIDs
16 lines (14 loc) • 516 B
JavaScript
class NumericUUID {
static generate(length = 20) {
if (length < 10 || length > 30) {
throw new Error("Length must be between 10 and 30 digits.");
}
let timestamp = Date.now().toString(); // Get current timestamp
let randomPart = "";
while (randomPart.length < length - timestamp.length) {
randomPart += Math.floor(Math.random() * 10); // Append random digits
}
return timestamp + randomPart;
}
}
module.exports = NumericUUID;