1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.getDisplayNameColor = void 0;
|
7 |
|
8 | function _crypto() {
|
9 | const data = require('crypto');
|
10 |
|
11 | _crypto = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | const colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
|
25 |
|
26 | const getDisplayNameColor = seed => {
|
27 | if (seed === undefined) {
|
28 | return 'white';
|
29 | }
|
30 |
|
31 | const hash = (0, _crypto().createHash)('sha256');
|
32 | hash.update(seed);
|
33 | const num = hash.digest().readUInt32LE(0);
|
34 | return colors[num % colors.length];
|
35 | };
|
36 |
|
37 | exports.getDisplayNameColor = getDisplayNameColor;
|