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

Function readLuaLibFeature

src/LuaLib.ts:178–189  ·  view source on GitHub ↗
(feature: LuaLibFeature, luaTarget: LuaTarget, emitHost: EmitHost)

Source from the content-addressed store, hash-verified

176const lualibFeatureCache = new Map<LuaTarget, Map<LuaLibFeature, string>>();
177
178export function readLuaLibFeature(feature: LuaLibFeature, luaTarget: LuaTarget, emitHost: EmitHost): string {
179 const featureMap = getOrUpdate(lualibFeatureCache, luaTarget, () => new Map());
180 if (!featureMap.has(feature)) {
181 const featurePath = path.join(resolveLuaLibDir(luaTarget), `${feature}.lua`);
182 const luaLibFeature = emitHost.readFile(featurePath);
183 if (luaLibFeature === undefined) {
184 throw new Error(`Could not load lualib feature from '${featurePath}'`);
185 }
186 featureMap.set(feature, luaLibFeature);
187 }
188 return featureMap.get(feature)!;
189}
190
191export function resolveRecursiveLualibFeatures(
192 features: Iterable<LuaLibFeature>,

Callers 2

lualib.spec.tsFile · 0.90
loadInlineLualibFeaturesFunction · 0.85

Calls 6

getOrUpdateFunction · 0.90
resolveLuaLibDirFunction · 0.85
readFileMethod · 0.80
hasMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected