Socket
Socket
Sign inDemoInstall

uuid-tool

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    uuid-tool

Parse and generate UUIDs. Convert between UUID string (36 byte) to 16 byte array.


Version published
Weekly downloads
1.1K
decreased by-29.16%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

UUID Tool

Parse and generate UUIDs. Convert between UUID string (36 byte) to 16 byte array. Inclusive TypeScript definition file (types).

UUID RFC 4122 Version 4

Install

npm i -S uuid-tool

Example

let uuid = UUIDTool.newUUID();
let bytes = UUIDTool.toBytes(uuid);
let strAgain = UUIDTool.toString(bytes);
let isValid = UUIDTool.isUUID(strAgain);

You can also use the UUID class.

let uuid = new UUID(byteOrString);
let str = uuid.toString();
let bytes = uuid.toBytes();

API


toBytes (uuid)

Converts an UUID string to an UUID byte array.

ParamTypeDescription
uuidstringUUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124'

Returns number UUID byte array (length: 16)


toString (bytes)

Converts an UUID byte array to an UUID string.

ParamTypeDescription
bytesnumber[]UUID Byte array (length 16 bytes of bytes)

Returns string UUID string. (length 36)


newUUID ()

Generates a new (pseudo) UUID RFC 4122 Version 4.

Returns string UUID e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124'


isUUID (uuid)

Converts an UUID byte array to an UUID string.

ParamTypeDescription
uuidstringUUID string e.g. '1FBD384C-B2A1-41C6-84AF-43CABDF44124'

Returns boolean True if valid, otherwise false.

License

Apache-2.0

(C) Copyright 2018 Dominik-Andreas Geng

Keywords

FAQs

Last updated on 20 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc