From f5df95e2df6146a725f87c98b188d991e6c6b130 Mon Sep 17 00:00:00 2001 From: howmanysmall Date: Thu, 16 Sep 2021 17:01:37 -0600 Subject: [PATCH] Janitor V1.13.7 --- src/Promise/init.lua | 19 ++++++++----------- src/Standard/init.lua | 17 +++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/Promise/init.lua b/src/Promise/init.lua index 6492aca..5235bf0 100644 --- a/src/Promise/init.lua +++ b/src/Promise/init.lua @@ -16,8 +16,8 @@ getmetatable(LinkToInstanceIndex).__tostring = function() return "LinkToInstanceIndex" end -local NOT_A_PROMISE = "Invalid argument #1 to 'Janitor:AddPromise' (Promise expected, got %s (%s))" local METHOD_NOT_FOUND_ERROR = "Object %s doesn't have method %s, are you sure you want to add it? Traceback: %s" +local NOT_A_PROMISE = "Invalid argument #1 to 'Janitor:AddPromise' (Promise expected, got %s (%s))" local Janitor = {} Janitor.ClassName = "Janitor" @@ -109,11 +109,11 @@ function Janitor.__index:Remove(Index: any): Janitor if MethodName then if MethodName == true then - task.spawn(Object) + Object() else local ObjectMethod = Object[MethodName] if ObjectMethod then - task.spawn(ObjectMethod, Object) + ObjectMethod(Object) end end @@ -148,17 +148,17 @@ end function Janitor.__index:Cleanup() if not self.CurrentlyCleaning then self.CurrentlyCleaning = nil - for Object, MethodName in next, self do + for Object, MethodName in pairs(self) do if Object == IndicesReference then continue end if MethodName == true then - task.spawn(Object) + Object() else local ObjectMethod = Object[MethodName] if ObjectMethod then - task.spawn(ObjectMethod, Object) + ObjectMethod(Object) end end @@ -167,10 +167,7 @@ function Janitor.__index:Cleanup() local This = self[IndicesReference] if This then - for Index in next, This do - This[Index] = nil - end - + table.clear(This) self[IndicesReference] = {} end @@ -242,7 +239,7 @@ function Janitor.__index:LinkToInstance(Object: Instance, AllowMultiple: boolean self:Cleanup() else while IsNilParented and Connection.Connected and ManualDisconnect.Connected do - task.wait() + task.wait(0) end if ManualDisconnect.Connected and IsNilParented then diff --git a/src/Standard/init.lua b/src/Standard/init.lua index 4996d65..f4a830f 100644 --- a/src/Standard/init.lua +++ b/src/Standard/init.lua @@ -84,11 +84,11 @@ function Janitor.__index:Remove(Index: any): Janitor if MethodName then if MethodName == true then - task.spawn(Object) + Object() else local ObjectMethod = Object[MethodName] if ObjectMethod then - task.spawn(ObjectMethod, Object) + ObjectMethod(Object) end end @@ -123,17 +123,17 @@ end function Janitor.__index:Cleanup() if not self.CurrentlyCleaning then self.CurrentlyCleaning = nil - for Object, MethodName in next, self do + for Object, MethodName in pairs(self) do if Object == IndicesReference then continue end if MethodName == true then - task.spawn(Object) + Object() else local ObjectMethod = Object[MethodName] if ObjectMethod then - task.spawn(ObjectMethod, Object) + ObjectMethod(Object) end end @@ -142,10 +142,7 @@ function Janitor.__index:Cleanup() local This = self[IndicesReference] if This then - for Index in next, This do - This[Index] = nil - end - + table.clear(This) self[IndicesReference] = {} end @@ -217,7 +214,7 @@ function Janitor.__index:LinkToInstance(Object: Instance, AllowMultiple: boolean self:Cleanup() else while IsNilParented and Connection.Connected and ManualDisconnect.Connected do - task.wait() + task.wait(0) end if ManualDisconnect.Connected and IsNilParented then