Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@somosphi/uuid

somosphi377MIT1.0.0TypeScript support: included

Utility functions for dealing with UUIDs

guid, uuid, string, buffer, binary, util

readme

@somosphi/uuid

Utility functions for dealing with UUIDs.

Installation

$ npm install @somosphi/uuid

Quick start

Using Node:

const Uuid = require('@somosphi/uuid');

Using Typescript:

import * as Uuid from '@somosphi/uuid';

Generating a random UUID (version 4)

const id = Uuid.generate();
console.log(id);
// => '28d53a31-8f6f-4939-a51e-d7dc0f81585f'

Converting a UUID in string format to binary

const binaryId = Uuid.stringToBinary(id);
console.log(binaryId);
// => <Buffer 28 d5 3a 31 8f 6f 49 39 a5 1e d7 dc 0f 81 58 5f>

Converting a UUID in binary format to a string

const stringId = Uuid.binaryToString(binaryId);
console.log(stringId);
// => '28d53a31-8f6f-4939-a51e-d7dc0f81585f'

changelog

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[Unreleased]

[1.0.0]

Added

  • Functions to create a new uuid, change the uuid from string to buffer and buffer to string