MCPcopy
hub / github.com/webpack/webpack / getUsed

Method getUsed

lib/ExportsInfo.js:1444–1476  ·  view source on GitHub ↗

* Returns usage state. * @param {RuntimeSpec} runtime for this runtime * @returns {UsageStateType} usage state

(runtime)

Source from the content-addressed store, hash-verified

1442 * @returns {UsageStateType} usage state
1443 */
1444 getUsed(runtime) {
1445 if (!this._hasUseInRuntimeInfo) return UsageState.NoInfo;
1446 if (this._globalUsed !== undefined) return this._globalUsed;
1447 if (this._usedInRuntime === undefined) {
1448 return UsageState.Unused;
1449 } else if (typeof runtime === "string") {
1450 const value = this._usedInRuntime.get(runtime);
1451 return value === undefined ? UsageState.Unused : value;
1452 } else if (runtime === undefined) {
1453 /** @type {UsageStateType} */
1454 let max = UsageState.Unused;
1455 for (const value of this._usedInRuntime.values()) {
1456 if (value === UsageState.Used) {
1457 return UsageState.Used;
1458 }
1459 if (max < value) max = value;
1460 }
1461 return max;
1462 }
1463
1464 /** @type {UsageStateType} */
1465 let max = UsageState.Unused;
1466 for (const item of runtime) {
1467 const value = this._usedInRuntime.get(item);
1468 if (value !== undefined) {
1469 if (value === UsageState.Used) {
1470 return UsageState.Used;
1471 }
1472 if (max < value) max = value;
1473 }
1474 }
1475 return max;
1476 }
1477
1478 /**
1479 * Returns used name. May return InlinedUsedName when the export is inlined to a primitive.

Callers 15

hasInfoMethod · 0.95
_updateHashMethod · 0.95
printExportsInfoToSourceFunction · 0.45
isUsedMethod · 0.45
isModuleUsedMethod · 0.45
getUsedExportsMethod · 0.45
getRelevantExportsMethod · 0.45
getUsageKeyMethod · 0.45
isEquallyUsedMethod · 0.45
getUsedMethod · 0.45
getUsedNameMethod · 0.45
hasInlinedUsedNameMethod · 0.45

Calls 2

getMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected