Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/core/uuid

core/uuid

This module provides API to generate, parse and serialize UUID strings and binary sequences.

Usage

import { generate, serialize, parse } from 'core/uuid';

// Generates UUID v4
console.log(generate());

const
uuid = new Uint8Array([174, 42, 253, 26, 185, 60, 17, 234, 179, 222, 2, 66, 172, 19, 0, 4]);

console.log(parse('ae2afd1a-b93c-11ea-b3de-0242ac130004')) // = uuid
console.log(serialize(uuid)) // 'ae2afd1a-b93c-11ea-b3de-0242ac130004'

generate

Generates a UUIDv4 buffer and returns it.

serialize

Converts the specified binary UUID to a string and returns it.

parse

Converts the specified UUID string to a binary sequence and returns it.

Index

Functions

  • generate(): Uint8Array
  • parse(uuid: string): Uint8Array
  • Converts the specified UUID string to a binary sequence and returns it

    Parameters

    • uuid: string

    Returns Uint8Array

  • serialize(uuid: Uint8Array): string
  • Converts the specified binary UUID to a string and returns it

    Parameters

    • uuid: Uint8Array

    Returns string