Module:Api

local p = {}

-- local helper function for retrieving the data function getData(modulePath) local noError, data = pcall( mw.loadData, modulePath ) if noError then return data end -- error( data ) return nil; end

-- Item Api methods

-- locally cache results - while this doesn't save memory (I think), it does save -- some computation time if multiple requires are done from a single invoke. -- This doesn't cache it between invokes though; normal mw.loadData cache must be depended on for that local __itemAliases = nil function p.getItemAliases if __itemAliases then return __itemAliases end __itemAliases = mw.loadData('Module:Item/ApiAliases')--mw.loadData('Module:Api/Item/Aliases') return __itemAliases end

function p.getItemData( itemid ) local aliases = p.getItemAliases itemid = itemid:upper:gsub(' ', '_') itemid = aliases[itemid] or itemid return getData('Module:Api/Item/' .. itemid) end

-- return return p