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

Method getUsed

lib/ExportsInfo.js:780–795  ·  view source on GitHub ↗

* Returns usage status. * @param {ExportInfoName | ExportInfoName[]} name export name * @param {RuntimeSpec} runtime check usage for this runtime only * @returns {UsageStateType} usage status

(name, runtime)

Source from the content-addressed store, hash-verified

778 * @returns {UsageStateType} usage status
779 */
780 getUsed(name, runtime) {
781 if (Array.isArray(name)) {
782 if (name.length === 0) return this.otherExportsInfo.getUsed(runtime);
783 // Walk the nested path iteratively to avoid a `slice` per level
784 /** @type {ExportsInfo} */
785 let exportsInfo = this;
786 const last = name.length - 1;
787 for (let i = 0; ; i++) {
788 const info = exportsInfo.getReadOnlyExportInfo(name[i]);
789 if (i === last || !info.exportsInfo) return info.getUsed(runtime);
790 exportsInfo = info.exportsInfo;
791 }
792 }
793 const info = this.getReadOnlyExportInfo(name);
794 return info.getUsed(runtime);
795 }
796
797 /**
798 * Returns the used name.

Callers

nothing calls this directly

Calls 3

getReadOnlyExportInfoMethod · 0.95
isArrayMethod · 0.80
getUsedMethod · 0.45

Tested by

no test coverage detected