function Rx.throttleTime(F,c)assert(type(F)=="\110\117\109\098\101\114","\066\097\100 \100\117\114\097\116\105\111\110")assert(type(c)=="\116\097\098\108\101"or c==nil,"\066\097\100 \116\104\114\111\116\116\108\101\067\111\110\102\105\103")return function(b)assert(Observable.isObservable(b),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(D)local W=Maid.new()local e=ThrottledFunction.new(F,function(...)D:Fire(...)end,c)W:GiveTask(e)W:GiveTask(b:Subscribe(function(...)e:Call(...)end,D:GetFailComplete()))return W end)end end
--[=[
	Throttles emission of observables.

	https://rxjs-dev.firebaseapp.com/api/operators/debounceTime

	:::note
	Note that on complete, the last item is not included, for now, unlike the existing version in rxjs.
	:::

	@param duration number
	@param throttleConfig { leading = true; trailing = true; }
	@return (source: Observable) -> Observable
]=]
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
