function Rx.throttleTime(n,R)assert(type(n)=="\110\117\109\098\101\114","\066\097\100 \100\117\114\097\116\105\111\110")assert(type(R)=="\116\097\098\108\101"or R==nil,"\066\097\100 \116\104\114\111\116\116\108\101\067\111\110\102\105\103")return function(Y)assert(Observable.isObservable(Y),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(z)local d=Maid.new()local l=ThrottledFunction.new(n,function(...)z:Fire(...)end,R)d:GiveTask(l)d:GiveTask(Y:Subscribe(function(...)l:Call(...)end,z:GetFailComplete()))return d end)end end

function Rx.throttleTime(duration, throttleConfig)
	assert(type(duration) == "number", "Bad duration")
	assert(type(throttleConfig) == "table" or throttleConfig == nil, "Bad throttleConfig")

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

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

			local throttledFunction = ThrottledFunction.new(duration, function(...)
				sub:Fire(...)
			end, throttleConfig)

			maid:GiveTask(throttledFunction)
			maid:GiveTask(source:Subscribe(function(...)
				throttledFunction:Call(...)
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end
