]>
git.r.bdr.sh - rbdr/forum/blob - src/utils/glyph_hash.js
13a81a8286af15555a980be11ce54ce39661ef66
2 kSplitterRegex: /.{1,8}/g,
3 kGlyphs: ['☽', '☆', '♢', '♡', '╱', '╲', '╳', '〰', '▷', '⏊', '〒', '▢', '◯', '⏃', '⏀', '⏆']
6 // Return a glyph with color based on a 4 byte fragment of a UUIDv4
7 const getGlyphHashFragment = function (uuidFragment
) {
9 const glyphIndex
= parseInt(uuidFragment
.substring(0, 2), 16) % 16;
11 glyph: internals
.kGlyphs
[glyphIndex
],
12 color: `#${uuidFragment.substring(2, 8)}`
16 // Return an array of glyphs based on a UUIDv4
17 export const getGlyphHash = function (uuid
) {
19 const hashFragments
= uuid
.replace(/[-]/g, '').match(internals
.kSplitterRegex
);
20 return hashFragments
.map(getGlyphHashFragment
);