function Rx.delay(R)assert(type(R)=="\110\117\109\098\101\114","\066\097\100 \115\101\099\111\110\100\115")return function(M)assert(Observable.isObservable(M),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(e)local l=Maid.new()l:GiveTask(M:Subscribe(function(...)local M=table.pack(...)l[M]=cancellableDelay(R,function()l[M]=nil e:Fire(table.unpack(M,1,M.n))end)end,e:GetFailComplete()))return l end)end end

function Rx.delay(seconds)
	assert(type(seconds) == "number", "Bad seconds")

	return function(source)
		assert(Observable.isObservable(source), "Bad observable")

		return Observable.new(function(sub)
			local maid = Maid.new()

			maid:GiveTask(source:Subscribe(function(...)
				local args = table.pack(...)

				maid[args] = cancellableDelay(seconds, function()
					maid[args] = nil
					sub:Fire(table.unpack(args, 1, args.n))
				end)
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end
