uuid

The uuid built-in module is available only inside a PubNub Function. It generates and validates RFC-compliant universally unique identifiers (UUIDs).

1const { v3, v4, v5, validate, version } = require('uuid');
MethodSignatureReturns
v3v3(name, namespace)UUID string derived from the MD5 hash of namespace and name.
v4v4()Random UUID string. Requires no arguments.
v5v5(name, namespace)UUID string derived from the SHA-1 hash of namespace and name.
validatevalidate(str)true if str is a valid UUID, otherwise false.
versionversion(str)The RFC version number of UUID str.
1const { v4, validate, version } = require('uuid');
2
3export default req => {
4 const uuid = v4();
5 return req.ok({
6 v4: uuid,
7 valid: validate(uuid),
8 version: version(uuid),
9 });
10};

Was this page useful?

Last updated on