This module provides a function that makes calling require() multiple times easy.
Features
- Provides a function to load multiple modules in one function call.
- Able to switch between a packed and unpacked table
Loading the module
To load this module and make its method available for use, Add this line of code to the start of your module:
local multiRequire = require('Module:MultiRequire')
All methods described below will be available under the loaded table.
Return function
This module returns a single function.
Parameters
multiRequire(module1: string[, module2: string, [, ...moduleN: string]]) -> unpacked<any>multiRequire{ module1: string[, module2: string, [, ...moduleN: string]] } -> any[]
Returns any values returned by require() are returned.
If the input is a table, it returns a table. If variable length arguments are used, it returns the unpacked values.
It will throw an error if the module is not found or if it failed to load.
Examples
multiRequire('Module:String')→<methods from Module:String>multiRequire{ 'Module:String', 'Module:Arguments' }→{ <methods from Module:String>, <methods from Module:Arguments> }
Example Code
local multiRequire = require('Module:MultiRequire')
local libraryUtil, arguments = multiRequire('libraryUtil', 'Dev:Arguments')
-- You can now use libraryUtil and Dev:Arguments