function Janitor.__index.AddPromise(e,Z)if not Promise.is(Z)then error(string.format(NOT_A_PROMISE,typeof(Z),tostring(Z)))end if Z:getStatus()==Promise.Status.Started then local t=newproxy(false)local U=e:Add(Promise.resolve(Z),"\099\097\110\099\101\108",t)U:finallyCall(e.Remove,e,t)return U else return Z end end
--[[**
	Adds a promise to the janitor. If the janitor is cleaned up and the promise is not completed, the promise will be cancelled.
	@param [t:Promise] PromiseObject The promise you want to add to the janitor.
	@returns [t:Promise]
**--]]
function Janitor.__index:AddPromise(PromiseObject)
	if not Promise.is(PromiseObject) then
		error(string.format(NOT_A_PROMISE, typeof(PromiseObject), tostring(PromiseObject)))
	end

	if PromiseObject:getStatus() == Promise.Status.Started then
		local Id = newproxy(false)
		local NewPromise = self:Add(Promise.resolve(PromiseObject), "cancel", Id)
		NewPromise:finallyCall(self.Remove, self, Id)
		return NewPromise
	else
		return PromiseObject
	end
end
