function PromiseUtils.invert(t)if t:IsPending()then return t:Then(function(...)return Promise.rejected(...)end,function(...)return Promise.resolved(...)end)else local s={t:GetResults()}if s[1]then return Promise.rejected(unpack(s,2))else return Promise.resolved(unpack(s,2))end end end
--[=[
	Inverts the result of a promise, turning a resolved promise
	into a rejected one, and a rejected one into a resolved one.

	@param promise Promise<T>
	@return Promise<T>
]=]
function PromiseUtils.invert(promise)
	if promise:IsPending() then
		return promise:Then(function(...)
			return Promise.rejected(...)
		end, function(...)
			return Promise.resolved(...)
		end)
	else
		local results = { promise:GetResults() }
		if results[1] then
			return Promise.rejected(unpack(results, 2))
		else
			return Promise.resolved(unpack(results, 2))
		end
	end
end
