Skip to content
Javascript UUID version 4 generator and parser - string and binary
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LICENSE.md
README.md
bower.json
package.json
uuid.js

README.md

uuid.js

Javascript UUID version 4 generator and parser - string and binary

Wikipedia UUID

  • runs in browsers and node.js
  • creates and parses uuids as string or binary

Install

  • Install with Bower: bower install opusonline-uuid.js.
  • Install with npm: npm install opusonline-uuid.js.

Usage

Return a valid v4 UUID.

var id = uuid();
// e.g "6ee65cf0-4fdc-4d33-b78d-d09e1294d80f"

Methods

create

Same as uuid().

var id = uuid.create();

createBinary

Return a v4 UUID as Uint8Array, Buffer or Array.

var bytes = uuid.createBinary();
// e.g. [110, 230, 92, 240, 79, 220, 77, 51, 183, 141, 208, 158, 18, 148, 216, 15]

parse

Parses a v4 UUID from string to binary

var bytes = uuid.parse('6ee65cf0-4fdc-4d33-b78d-d09e1294d80f');
// gives [110, 230, 92, 240, 79, 220, 77, 51, 183, 141, 208, 158, 18, 148, 216, 15]

parseBinary

Parses a v4 UUID from binary to string

var bytes = new Uint8Array([110, 230, 92, 240, 79, 220, 77, 51, 183, 141, 208, 158, 18, 148, 216, 15]);
var id = uuid.parseBinary(bytes);
// gives "6ee65cf0-4fdc-4d33-b78d-d09e1294d80f"
Something went wrong with that request. Please try again.