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');
| Method | Signature | Returns |
|---|---|---|
v3 | v3(name, namespace) | UUID string derived from the MD5 hash of namespace and name. |
v4 | v4() | Random UUID string. Requires no arguments. |
v5 | v5(name, namespace) | UUID string derived from the SHA-1 hash of namespace and name. |
validate | validate(str) | true if str is a valid UUID, otherwise false. |
version | version(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};
Related reference
- Modules and libraries. Every built-in module available inside a Function.