-- Compiled with roblox-ts v2.0.4 local ProtonUtil = {} do local _container = ProtonUtil --[[ * * Load Mode for `ProtonUtil.loadModules()` function. ]] local LoadMode do local _inverse = {} LoadMode = setmetatable({}, { __index = _inverse, }) LoadMode.Children = 0 _inverse[0] = "Children" LoadMode.Descendants = 1 _inverse[1] = "Descendants" end _container.LoadMode = LoadMode --[[ * * Load all modules within the parent of the calling script. * An optional `matchName` and `loadMode` can be provided * to help dictate the load behavior. * * ```ts * // Load all children ModuleScripts * ProtonUtil.loadModules(); * * // Load all descendant ModuleScripts * ProtonUtil.loadModules(undefined, ProtonUtil.LoadMode.Descendants); * * // Load all ModuleScripts that end with '-service' * ProtonUtil.loadModules("%-service$", ProtonUtil.LoadMode.Descendants); * ``` * * @param matchName Only load ModuleScripts that match the given pattern * @param loadMode LoadMode enum to indicate scanning direct children or all descendants ]] local function loadModules(parent, matchName, loadMode) if loadMode == nil then loadMode = LoadMode.Children end local instances = if loadMode == LoadMode.Children then parent:GetChildren() else parent:GetDescendants() for _, instance in instances do if instance:IsA("ModuleScript") then local _condition = matchName == nil if not _condition then local _name = instance.Name local _matchName = matchName _condition = (string.match(_name, _matchName)) ~= nil end if _condition then require(instance) end end end end _container.loadModules = loadModules end return { ProtonUtil = ProtonUtil, }