source: imaps-frontend/node_modules/webpack/lib/util/nonNumericOnlyHash.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 562 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
8const A_CODE = "a".charCodeAt(0);
9
10/**
11 * @param {string} hash hash
12 * @param {number} hashLength hash length
13 * @returns {string} returns hash that has at least one non numeric char
14 */
15module.exports = (hash, hashLength) => {
16 if (hashLength < 1) return "";
17 const slice = hash.slice(0, hashLength);
18 if (/[^\d]/.test(slice)) return slice;
19 return `${String.fromCharCode(
20 A_CODE + (Number.parseInt(hash[0], 10) % 6)
21 )}${slice.slice(1)}`;
22};
Note: See TracBrowser for help on using the repository browser.