MCPcopy
hub / github.com/webpack/webpack / getPresentKinds

Function getPresentKinds

lib/TemplatedPathPlugin.js:48–70  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

46 * @returns {Set<string>} placeholder kinds present
47 */
48const getPresentKinds = (path) => {
49 const cached = presentKindsCache.get(path);
50 if (cached !== undefined) return cached;
51 /** @type {Set<string>} */
52 const kinds = new Set();
53 // `RegExp.exec` loop rather than `String.matchAll` (Node.js 12+) so this
54 // stays compatible with the supported Node.js 10 range.
55 REGEXP.lastIndex = 0;
56 /** @type {RegExpExecArray | null} */
57 let m;
58 while ((m = REGEXP.exec(path)) !== null) {
59 const content = /** @type {string} */ (m[1]);
60 if (content.length + 2 === m[0].length) {
61 const cm = /^(\w+)(?::\w+)?(?::\w+)?$/.exec(content);
62 if (cm) kinds.add(cm[1]);
63 }
64 }
65 if (presentKindsCache.size >= PRESENT_KINDS_CACHE_MAX) {
66 presentKindsCache.clear();
67 }
68 presentKindsCache.set(path, kinds);
69 return kinds;
70};
71
72/** @type {PathData["prepareId"]} */
73const prepareId = (id) => {

Callers 5

usesFullHashFunction · 0.85
applyMethod · 0.85
interpolateFunction · 0.85
constructorMethod · 0.85

Calls 5

execMethod · 0.80
getMethod · 0.45
addMethod · 0.45
clearMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected