MCPcopy
hub / github.com/webpack/webpack / fn

Function fn

lib/TemplatedPathPlugin.js:217–255  ·  view source on GitHub ↗
(match, arg, input, digest)

Source from the content-addressed store, hash-verified

215) => {
216 /** @type {Replacer} */
217 const fn = (match, arg, input, digest) => {
218 /** @type {string} */
219 let result;
220 const length = arg && Number.parseInt(arg, 10);
221
222 if (digest && digestHandler) {
223 result = digestHandler(digest, length || undefined);
224 } else if (digest) {
225 const hash = reEncodeDigest(
226 fullValue !== undefined ? fullValue : replacer(match, arg, input),
227 sourceDigest,
228 digest
229 );
230 result = length ? hash.slice(0, length) : hash;
231 } else if (length && handler) {
232 result = handler(length);
233 } else {
234 const hash = replacer(match, arg, input);
235
236 result = length ? hash.slice(0, length) : hash;
237 }
238 if (assetInfo) {
239 assetInfo.immutable = true;
240 if (digest && recordDigest) {
241 // `base64safe` is encoded as `base64url`; record what the value is in.
242 (assetInfo.contenthashDigest || (assetInfo.contenthashDigest = {}))[
243 result
244 ] = digest === "base64safe" ? "base64url" : digest;
245 }
246 if (Array.isArray(assetInfo[hashName])) {
247 assetInfo[hashName] = [...assetInfo[hashName], result];
248 } else if (assetInfo[hashName]) {
249 assetInfo[hashName] = [assetInfo[hashName], result];
250 } else {
251 assetInfo[hashName] = result;
252 }
253 }
254 return result;
255 };
256
257 return fn;
258};

Callers 1

deprecatedFunction · 0.70

Calls 6

reEncodeDigestFunction · 0.85
replacerFunction · 0.85
valueFunction · 0.85
sliceMethod · 0.80
isArrayMethod · 0.80
handlerFunction · 0.50

Tested by

no test coverage detected