Module basic module

Module uuid

uuid unique id module

Basic module. Provide unique id created in operation

1
var uuid = require('uuid');

Static function

node

Create uuid with time and hostname

1
static Buffer uuid.node();

Return result:

  • Buffer , returns a generated binary id

md5

Create uuid with a specific named md5

1 2
static Buffer uuid.md5(Integer ns, String name);

Call parameters:

Return result:

  • Buffer , returns a generated binary id

random

Use random number to create uuid

1
static Buffer uuid.random();

Return result:

  • Buffer , returns a generated binary id

sha1

Create uuid with a specifically named sha1

1 2
static Buffer uuid.sha1(Integer ns, String name);

Call parameters:

Return result:

  • Buffer , returns a generated binary id

snowflake

Use Snowflake algorithm to create uuid

1
static Buffer uuid.snowflake();

Return result:

  • Buffer , returns a generated binary id

Static properties

hostID

Integer, query and modify the host id of the Snowflake algorithm

1
static Integer uuid.hostID;

constant

DNS

When md5 and sha1 create uuid, specify the name as the domain name

1
const uuid.DNS = 0;

URL

When md5 and sha1 create uuid, specify name as url address

1
const uuid.URL = 1;

OID

When md5 and sha1 create uuid, specify the name as ISO OID

1
const uuid.OID = 2;

X509

When md5 and sha1 create uuid, specify the name as X.500 DN

1
const uuid.X509 = 3;