Skip to content

Add Option to Retain UUID Format Instead of Base64 Encoding #39

@salmanm

Description

@salmanm

Hyperid’s principle is indeed great, using a UUID + counter avoids unnecessary UUID generations while keeping it sequential within a single instance. However, Hyperid doesn’t support retaining the original UUID format. It currently encodes the UUID into Base64, making it more compact but harder to read and manipulate. It would be beneficial to have an option to retain the UUID in its original format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) while still appending the counter as usual.

Use Case & Benefits

  • Improved Readability: The standard UUID format is widely recognized, making logs/debugging easier.
  • Easier Integration: Many systems expect UUIDs in their native format rather than Base64.
  • No Performance Hit: Avoids the extra encoding/decoding step while keeping Hyperid’s efficiency.

Proposed Solution

Introduce an option to disable Base64 encoding, allowing users to get the UUID in its standard format. Example API:

const hyperid = require('hyperid')({ format: 'uuid' }); // Default could remain 'base64'
console.log(hyperid()); // Outputs: "049b7020-c787-41bf-a1d2-a97612c11418-0"
console.log(hyperid()); // Outputs: "049b7020-c787-41bf-a1d2-a97612c11418-1"

Would love to hear your thoughts on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions