MCPcopy
hub / github.com/webpack/webpack / nonNumericOnlyHash

Function nonNumericOnlyHash

lib/util/nonNumericOnlyHash.js:18–25  ·  view source on GitHub ↗
(hash, hashLength)

Source from the content-addressed store, hash-verified

16 * @returns {string} returns hash that has at least one non numeric char
17 */
18const 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).

Callers 4

getFullContentHashMethod · 0.85
digestNonNumericOnlyFunction · 0.85

Calls 2

sliceMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected