Skip to content

Commit

Permalink
Add types to SplitChunksPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ooflorent committed Dec 10, 2018
1 parent 760b1da commit 5f26040
Show file tree
Hide file tree
Showing 2 changed files with 377 additions and 185 deletions.
13 changes: 13 additions & 0 deletions lib/ids/IdHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const { makePathsRelative } = require("../util/identifier");
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module")} Module */

/**
* @param {string} str string to hash
* @param {number} len max length of the hash
* @returns {string} hash
*/
const getHash = (str, len) => {
const hash = createHash("md4");
hash.update(str);
Expand All @@ -37,13 +42,21 @@ const getHashNumber = (str, len) => {
.join("");
};

/**
* @param {string} str the string
* @returns {string} string prefixed by an underscore if it is a number
*/
const avoidNumber = str => {
if (str === +str + "") {
return `_${str}`;
}
return str;
};

/**
* @param {string} request the request
* @returns {string} id representation
*/
const requestToId = request => {
return request
.replace(/^(\.\.?\/)+/, "")
Expand Down
Loading

0 comments on commit 5f26040

Please sign in to comment.