uuid-generator-krishnarao
v1.0.1
Published
A TypeScript library for generating UUIDs
Maintainers
Readme
UUID Generator Library
A TypeScript library for generating universally unique identifiers (UUIDs) version 4.
Installation
npm install uuid-generator-krishnaraoUsage
Basic Usage
import { generateUUID, generateUUIDs, isValidUUID } from 'uuid-generator-krishnarao';
// Generate a single UUID
const uuid = generateUUID();
console.log(uuid); // "12345678-1234-4123-8123-123456789012"
// Generate multiple UUIDs
const uuids = generateUUIDs(5);
console.log(uuids); // ["uuid1", "uuid2", "uuid3", "uuid4", "uuid5"]
// Validate a UUID
const isValid = isValidUUID("12345678-1234-4123-8123-123456789012");
console.log(isValid); // trueAdvanced Usage
import {
generatePrefixedUUID,
generateUUIDCompact
} from 'uuid-generator-krishnarao';
// Generate UUID with prefix
const prefixedUUID = generatePrefixedUUID("user");
console.log(prefixedUUID); // "user-12345678-1234-4123-8123-123456789012"
// Generate compact UUID (without hyphens)
const compactUUID = generateUUIDCompact();
console.log(compactUUID); // "12345678123441238123123456789012"API Reference
generateUUID(): string
Generates a random UUID v4 string.
generateUUIDs(count: number): string[]
Generates an array of UUIDs.
count: Number of UUIDs to generate
isValidUUID(uuid: string): boolean
Validates if a string is a valid UUID v4 format.
uuid: The string to validate
generatePrefixedUUID(prefix: string): string
Generates a UUID with a custom prefix.
prefix: The prefix to add before the UUID
generateUUIDCompact(): string
Generates a UUID without hyphens (32 characters).
Development
Building the Library
npm run buildRunning Tests
npm testDevelopment Server
npm run dev