Comparison

util/import.lua @ 8570:a4ef8cfa97bd

util.import: Explicitly export the global import function [luacheck]
author Kim Alvefur <zash@zash.se>
date Wed, 07 Mar 2018 19:22:07 +0100
parent 8389:5d866eb8f18f
child 9692:affcbccc1dff
comparison
equal deleted inserted replaced
8569:f88bd2428bc2 8570:a4ef8cfa97bd
8 8
9 9
10 10
11 local unpack = table.unpack or unpack; --luacheck: ignore 113 143 11 local unpack = table.unpack or unpack; --luacheck: ignore 113 143
12 local t_insert = table.insert; 12 local t_insert = table.insert;
13 function import(module, ...) 13 function _G.import(module, ...)
14 local m = package.loaded[module] or require(module); 14 local m = package.loaded[module] or require(module);
15 if type(m) == "table" and ... then 15 if type(m) == "table" and ... then
16 local ret = {}; 16 local ret = {};
17 for _, f in ipairs{...} do 17 for _, f in ipairs{...} do
18 t_insert(ret, m[f]); 18 t_insert(ret, m[f]);