* Returns usage state. * @param {RuntimeSpec} runtime for this runtime * @returns {UsageStateType} usage state
(runtime)
| 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. |
no test coverage detected