feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -77,24 +77,19 @@ function fnv1a64(str) {
*
* We use `numberHash` in `lib/ids/IdHelpers.js` to generate hash values for the module identifier. The generated
* hash is used as a prefix for the module id's to avoid collisions with other modules.
*
* @param {string} str The input string to hash.
* @param {number} range The range of the hash value (0 to range-1).
* @returns {number} - The computed hash value.
*
* @example
*
* ```js
* const numberHash = require("webpack/lib/util/numberHash");
* numberHash("hello", 1000); // 73
* numberHash("hello world"); // 72
* ```
*
*/
module.exports = (str, range) => {
if (range < FNV_64_THRESHOLD) {
return fnv1a32(str) % range;
} else {
return Number(fnv1a64(str) % BigInt(range));
}
return Number(fnv1a64(str) % BigInt(range));
};