|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
618 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Ivan Kopeykin @vankop
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | const A_CODE = "a".charCodeAt(0);
|
|---|
| 9 |
|
|---|
| 10 | /**
|
|---|
| 11 | * Returns hash that has at least one non numeric char.
|
|---|
| 12 | * @param {string} hash hash
|
|---|
| 13 | * @param {number} hashLength hash length
|
|---|
| 14 | * @returns {string} returns hash that has at least one non numeric char
|
|---|
| 15 | */
|
|---|
| 16 | module.exports = (hash, hashLength) => {
|
|---|
| 17 | if (hashLength < 1) return "";
|
|---|
| 18 | const slice = hash.slice(0, hashLength);
|
|---|
| 19 | if (/[^\d]/.test(slice)) return slice;
|
|---|
| 20 | return `${String.fromCharCode(
|
|---|
| 21 | A_CODE + (Number.parseInt(hash[0], 10) % 6)
|
|---|
| 22 | )}${slice.slice(1)}`;
|
|---|
| 23 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.