MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / findUsedLualibFeatures

Function findUsedLualibFeatures

src/LuaLib.ts:292–313  ·  view source on GitHub ↗
(
    luaTarget: LuaTarget,
    emitHost: EmitHost,
    luaContents: string[]
)

Source from the content-addressed store, hash-verified

290}
291
292export function findUsedLualibFeatures(
293 luaTarget: LuaTarget,
294 emitHost: EmitHost,
295 luaContents: string[]
296): Set<LuaLibFeature> {
297 const features = new Set<LuaLibFeature>();
298 const exportToFeatureMap = getLuaLibExportToFeatureMap(luaTarget, emitHost);
299
300 for (const lua of luaContents) {
301 const regex = /^local (\w+) = ____lualib\.(\w+)$/gm;
302 while (true) {
303 const match = regex.exec(lua);
304 if (!match) break;
305 const [, localName, exportName] = match;
306 if (localName !== exportName) continue;
307 const feature = exportToFeatureMap.get(exportName);
308 if (feature) features.add(feature);
309 }
310 }
311
312 return features;
313}

Callers 1

Calls 3

addMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected