Skip to content

[BUG] Short arrays from options.rng() or options.random result in invalid UUIDs #846

@broofa

Description

@broofa

Description of the problem

Reporting on behalf of @gaoyia

If options.rng() or options.random evaluates to a too-short array (< 16 bytes), the resulting UUID is invalid.

Recipe for reproducing

import {v4} from 'uuid';
console.log(v4({random: new Uint8Array(15)}));
// -> 00000000-0000-4000-8000-0000000000undefined

Additional information

No response

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions