MCPcopy
hub / github.com/webpack/webpack / getHash

Function getHash

lib/ids/IdHelpers.js:28–33  ·  view source on GitHub ↗
(str, len, hashFunction)

Source from the content-addressed store, hash-verified

26 * @returns {string} hash
27 */
28const getHash = (str, len, hashFunction) => {
29 const hash = createHash(hashFunction);
30 hash.update(str);
31 const digest = hash.digest("hex");
32 return digest.slice(0, len);
33};
34
35/**
36 * Returns string prefixed by an underscore if it is a number.

Callers 2

shortenLongStringFunction · 0.70
getLongModuleNameFunction · 0.70

Calls 4

createHashFunction · 0.85
sliceMethod · 0.80
updateMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected