Skip to content

Add support for formatted UUIDs to the "from()" method. #60

@louis-vinchon

Description

@louis-vinchon

The library has several formating options, which is nice, however it only understands one of them when you "parse" a string with the from() method, which is weird.

Steps to reproduce:

const MUUID = require('uuid-mongodb');

const uuid1 = MUUID.v4();
console.log(uuid1); // Binary { ... }
const string = uuid1.toString('N');
console.log(string); // 9cea27b4d0e44781826ede1b6f378d6f

const uuid2 = MUUID.from(string); // Error: Invalid UUID

An optional parsing parameter like we have in the toString method would make a lot of sense, e.g. MUUID.from(string, 'N');

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions