(hash, hashLength)
| 16 | * @returns {string} returns hash that has at least one non numeric char |
| 17 | */ |
| 18 | const nonNumericOnlyHash = (hash, hashLength) => { |
| 19 | if (hashLength < 1) return ""; |
| 20 | const slice = hash.slice(0, hashLength); |
| 21 | if (/[^\d]/.test(slice)) return slice; |
| 22 | return `${String.fromCharCode( |
| 23 | A_CODE + (Number.parseInt(hash[0], 10) % 6) |
| 24 | )}${slice.slice(1)}`; |
| 25 | }; |
| 26 | |
| 27 | /** |
| 28 | * Digests a hash and truncates it to a content-hash string (non-numeric first char). |
no test coverage detected