Skip to content

Commit

Permalink
Janitor V1.13.7
Browse files Browse the repository at this point in the history
howmanysmall committed Sep 16, 2021
1 parent 87f8d36 commit f5df95e
Showing 2 changed files with 15 additions and 21 deletions.
19 changes: 8 additions & 11 deletions src/Promise/init.lua
Original file line number Diff line number Diff line change
@@ -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
17 changes: 7 additions & 10 deletions src/Standard/init.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f5df95e

Please sign in to comment.