aboutsummaryrefslogtreecommitdiff
path: root/src/utils/glyph_hash.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/glyph_hash.js')
-rw-r--r--src/utils/glyph_hash.js49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/utils/glyph_hash.js b/src/utils/glyph_hash.js
deleted file mode 100644
index 3758601..0000000
--- a/src/utils/glyph_hash.js
+++ /dev/null
@@ -1,49 +0,0 @@
-const internals = {
- kDehyphenRegex: /[-]/g,
- kSplitterRegex: /.{1,8}/g,
- kGlyphs: [
- '☽',
- '☆',
- '♢',
- '♡',
- '╱',
- '╲',
- '╳',
- '〰',
- '▷',
- '⏊',
- '〒',
- '▢',
- '◯',
- '⏃',
- '⏀',
- '⏆'
- ],
- unexpectedUUIDLength: class UnexpectedUUIDLength extends Error {
- name = 'UnexpectedUUIDLength';
- message = 'The provided string was not a valid UUIDv4, please provide a 32 character long string'
- }
-};
-
-// Return a glyph with color based on a 4 byte fragment of a UUIDv4
-const getGlyphHashFragment = function (uuidFragment) {
-
- const glyphIndex = parseInt(uuidFragment.substring(0, 2), 16) % 16;
- return {
- glyph: internals.kGlyphs[glyphIndex],
- color: `#${uuidFragment.substring(2, 8)}`
- };
-};
-
-// Return an array of glyphs based on a UUIDv4
-export const getGlyphHash = function (uuid) {
-
- const dehyphenedUuid = uuid.replace(/[-]/g, '');
-
- if (dehyphenedUuid.length !== 32) {
- throw new internals.unexpectedUUIDLength();
- }
-
- const hashFragments = dehyphenedUuid.match(internals.kSplitterRegex);
- return hashFragments.map(getGlyphHashFragment);
-};