function Janitor.__index.Add(M,j,H,A)if A==nil then A=newproxy(false)end if A then M:Remove(A)local H=M[IndicesReference]if not H then H={}M[IndicesReference]=H end H[A]=j end H=H or TypeDefaults[typeof(j)]or"\068\101\115\116\114\111\121"if type(j)~="\102\117\110\099\116\105\111\110"and not j[H]then warn(string.format(METHOD_NOT_FOUND_ERROR,tostring(j),tostring(H),debug.traceback(nil,2)))end M[j]=H return j,A end Janitor.__index.Give=Janitor.__index.Add

function Janitor.__index:Add(Object, MethodName, Index)
	if Index == nil then
		Index = newproxy(false)
	end

	if Index then
		self:Remove(Index)

		local This = self[IndicesReference]
		if not This then
			This = {}
			self[IndicesReference] = This
		end

		This[Index] = Object
	end
	--[[
	if Promise.is(Object) then
		local Id = newproxy(false)
		if Object:getStatus() == Promise.Status.Started then
			local NewPromise = self:Add(Promise.resolve(Object), "cancel", Id)
			NewPromise:finallyCall(self.Remove, self, Id)
			return NewPromise, Id
		else
			return Object
		end
	end--]]

	MethodName = MethodName or TypeDefaults[typeof(Object)] or "Destroy"
	if type(Object) ~= "function" and not Object[MethodName] then
		warn(string.format(METHOD_NOT_FOUND_ERROR, tostring(Object), tostring(MethodName), debug.traceback(nil, 2)))
	end

	self[Object] = MethodName
	return Object, Index
end

Janitor.__index.Give = Janitor.__index.Add
