ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# uuid 简单,快速生成RFC4122 UUIDS。 特点: 支持版本1,3,4和5 UUID 跨平台 使用加密强大的随机数API(如果可用) 零依赖,占用的空间很小 > 警告:不推荐使用require('uuid'),在此模块的3.x版之后将不再支持。 相反,使用require('uuid / [v1 | v3 | v4 | v5]'),如下面的示例所示。 Version 1 (timestamp): ~~~ const uuidv1 = require('uuid/v1'); uuidv1(); // ⇨ '45745c60-7b1a-11e8-9c9c-2d42b21b1a3e' ~~~ Version 3 (namespace): ~~~ const uuidv3 = require('uuid/v3'); // ... using predefined DNS namespace (for domain names) uuidv3('hello.example.com', uuidv3.DNS); // ⇨ '9125a8dc-52ee-365b-a5aa-81b0b3681cf6' // ... using predefined URL namespace (for, well, URLs) uuidv3('http://example.com/hello', uuidv3.URL); // ⇨ 'c6235813-3ba4-3801-ae84-e0a6ebb7d138' // ... using a custom namespace // // Note: Custom namespaces should be a UUID string specific to your application! // E.g. the one here was generated using this modules `uuid` CLI. const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; uuidv3('Hello, World!', MY_NAMESPACE); // ⇨ 'e8b5a51d-11c8-3310-a6ab-367563f20686' ~~~ Version 4 (random): ~~~ const uuidv4 = require('uuid/v4'); uuidv4(); // ⇨ '10ba038e-48da-487b-96e8-8d3b99b6d18a' ~~~ Version 5 (namespace): ~~~ const uuidv5 = require('uuid/v5'); // ... using predefined DNS namespace (for domain names) uuidv5('hello.example.com', uuidv5.DNS); // ⇨ 'fdda765f-fc57-5604-a269-52a7df8164ec' // ... using predefined URL namespace (for, well, URLs) uuidv5('http://example.com/hello', uuidv5.URL); // ⇨ '3bbcee75-cecc-5b56-8031-b6641c1ed1f1' // ... using a custom namespace // // Note: Custom namespaces should be a UUID string specific to your application! // E.g. the one here was generated using this modules `uuid` CLI. const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; uuidv5('Hello, World!', MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681' ~~~