--[=[
	@param object any -- Object to track
	@param cleanupMethod string? -- Optional cleanup name override
	@return object: any
	Adds an object to the Janitor. Once the Janitor is cleaned or
	destroyed, the object will also be cleaned up.

	The object must be any of the following:
	- Roblox instance (e.g. Part)
	- RBXScriptConnection (e.g. `workspace.ChildAdded:Connect(function() end)`)
	- Function
	- Table with either a `Destroy` or `Disconnect` method
	- Table with custom `cleanupMethod` name provided

	Returns the object added.

	```lua
	-- Add a part to the Janitor, then destroy the Janitor,
	-- which will also destroy the part:
	local part = Instance.new("Part")
	Janitor:Add(part)
	Janitor:Destroy()

	-- Add a function to the Janitor:
	Janitor:Add(function()
		print("Cleanup!")
	end)
	Janitor:Destroy()

	-- Standard cleanup from table:
	local tbl = {}
	function tbl:Destroy()
		print("Cleanup")
	end
	Janitor:Add(tbl)

	-- Custom cleanup from table:
	local tbl = {}
	function tbl:DoSomething()
		print("Do something on cleanup")
	end
	Janitor:Add(tbl, "DoSomething")
	```
]=]

function Janitor:Add(object: any, cleanupMethod: string?): any
	local cleanup = GetObjectCleanupFunction(object, cleanupMethod)
	table.insert(self._objects, {object, cleanup})
	return object
end

