function Promise.prototype.timeout(v,Q,I)local X=debug.traceback(nil,2)return Promise.race({(Promise.delay(Q)):andThen(function()return Promise.reject(I==nil and Error.new({kind=Error.Kind.TimedOut;error="\084\105\109\101\100 \111\117\116",context=string.format("\084\105\109\101\111\117\116 \111\102 \037\100 \115\101\099\111\110\100\115 \101\120\099\101\101\100\101\100\046\n\058\116\105\109\101\111\117\116\040\041 \099\097\108\108\101\100 \097\116\058\n\n\037\115",Q,X)})or I)end);v})end

function Promise.prototype:timeout(seconds, rejectionValue)
	local traceback = debug.traceback(nil, 2)

	return Promise.race({
		Promise.delay(seconds):andThen(function()
			return Promise.reject(rejectionValue == nil and Error.new({
				kind = Error.Kind.TimedOut,
				error = "Timed out",
				context = string.format(
					"Timeout of %d seconds exceeded.\n:timeout() called at:\n\n%s",
					seconds,
					traceback
				),
			}) or rejectionValue)
		end),
		self,
	})
end
