UNPKG

717 BJavaScriptView Raw
1"use strict";
2
3const uuidv5 = require(`uuid/v5`);
4
5const report = require(`gatsby-cli/lib/reporter`);
6
7const seedConstant = `638f7a53-c567-4eca-8fc1-b23efb1cfb2b`;
8/**
9 * createNodeId() Generate UUID
10 *
11 * @param {String} id - A string of arbitrary length
12 * @param {String} namespace - Namespace to use for UUID
13 *
14 * @return {String} - UUID
15 */
16
17function createNodeId(id, namespace) {
18 if (typeof id === `number`) {
19 id = id.toString();
20 } else if (typeof id !== `string`) {
21 report.panic(`Parameter passed to createNodeId must be a String or Number (got ${typeof id})`);
22 }
23
24 return uuidv5(id, uuidv5(namespace, seedConstant));
25}
26
27module.exports = createNodeId;
28//# sourceMappingURL=create-node-id.js.map
\No newline at end of file