Po redaktohet
Moduli:load
Kërceni tek navigimi
Kërceni tek kërkimi
Kujdes:
S’jeni i regjistruar. Adresa juaj IP do të jetë e dukshme publikisht, nëse bëni ndonjë redaktim. Nëse
hyni
ose
krijoni një llogari
, përveç përfitimesh të tjera, redaktimet tuaja do t’i atribuohen emrit tuaj të përdoruesit.
Kontrolli anti-spam.
Mos
e plotëso këtë!
local export = {} local load_data = mw.loadData local loaded = package.loaded local main_loader = package.loaders[2] local require = require local setmetatable = setmetatable local loaders, loaded_data, mt local function get_mt() mt, get_mt = {__mode = "kv"}, nil return mt end -- main_loader returns a loader function if the module exists, or nil if it doesn't. local function get_loader(modname) if loaders == nil then local loader = main_loader(modname) loaders = setmetatable({[modname] = loader or false}, mt or get_mt()) return loader end local loader = loaders[modname] if loader == nil then loader = main_loader(modname) loaders[modname] = loader or false end return loader or nil end local function get_data(modname, loader) if loaded_data == nil then local data = load_data(modname) loaded_data = setmetatable({[loader] = data}, mt or get_mt()) return data end local data = loaded_data[loader] if data == nil then data = load_data(modname) loaded_data[loader] = data end return data end --[==[ Like `require`, but returns `nil` if a module does not exist, instead of throwing an error. Outputs are cached, which is faster for all modules, but much faster for nonexistent modules, since `require` will attempt to use the full loader each time because loading failures don't get cached.]==] function export.safe_require(modname) local mod = loaded[modname] if mod == nil and get_loader(modname) then -- Call with require instead of the loader directly, as it protects against infinite loading loops. return require(modname) end return mod end --[==[ Like `mw.loadData`, but it does not generate a new table each time the same module is loaded via this function. Instead, it caches the returned data so that the same table can be returned each time, which is more efficient.]==] function export.load_data(modname) return get_data(modname, get_loader(modname)) end --[==[ Like `export.load_data` (itself a variant of `mw.loadData`), but returns `nil` if a module does not exist, instead of throwing an error. Outputs are cached, which is faster for all modules, but much faster for nonexistent modules, since `mw.loadData` will attempt to use the full loader each time because loading failures don't get cached.]==] function export.safe_load_data(modname) local loader = get_loader(modname) if loader == nil then return nil end return get_data(modname, loader) end return export
Përmbledhje:
Ju lutemi, vini re! Të gjitha kontributet në Enciklopedi Puro Shqiptare jepen për publikim sipas Creative Commons Attribution (shiko
Project:Të drejtat e autorit
për më shumë detaje). Nëse ju nuk dëshironi që shkrimet tuaja të redaktohen pa mëshirë dhe të shpërndahen sipas dëshirës, atëherë mos i vendosni këtu.
Gjithashtu, ju po na premtoni ne që gjithçka e keni shkruar vetë, ose e keni kopjuar nga një domain publik ose nga burime të tjera te hapura.
Mos vendosni material të mbrojtur nga e drejta e autorit pa leje!
Anuloje
Ndihmë për redaktim
(hapet në një dritare të re)
Stamp të përdorura në këtë faqe:
Moduli:load/doc
(
redakto
)
Menu lëvizjesh
Mjetet e mia
Nuk keni hyrë brenda
Diskutimi
Kontribute
Krijo llogari
Hyni
Emërhapësira
Moduli
Diskutim
English
Shikime
Lexo
Përpunoni burim
Shihni historikun
Më shumë
Kërko
Lëvizje
Faqja kryesore
Ndryshimet e fundit
Faqe e rastit
Ndihmë rreth MediaWiki-t
Faqet e veçanta
Mjete
Lidhjet këtu
Ndryshime të ndërvarura
Informacioni i faqes