function Rx.take(m)assert(type(m)=="\110\117\109\098\101\114","\066\097\100 \110\117\109\098\101\114")assert(m>0,"\066\097\100 \110\117\109\098\101\114")return function(U)assert(Observable.isObservable(U),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(q)local n=0 local s=Maid.new()s:GiveTask(U:Subscribe(function(...)if n>=m then warn("\091\082\120\046\116\097\107\101\093 - \083\116\105\108\108 \103\101\116\116\105\110\103 \118\097\108\117\101\115 \112\097\115\116 \115\117\098\115\099\114\105\112\116\105\111\110")return end n=n+1 q:Fire(...)if n>=m then q:Complete()end end,q:GetFailComplete()))return s end)end end
--[=[
	Takes n entries and then completes the observation.

	https://rxjs.dev/api/operators/take
	@param number number
	@return (source: Observable<T>) -> Observable<T>
]=]
function Rx.take(number)
	assert(type(number) == "number", "Bad number")
	assert(number > 0, "Bad number")

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

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

			maid:GiveTask(source:Subscribe(function(...)
				if taken >= number then
					warn("[Rx.take] - Still getting values past subscription")
					return
				end

				taken = taken + 1
				sub:Fire(...)

				if taken >= number then
					sub:Complete()
				end
			end, sub:GetFailComplete()))

			return maid
		end)
	end
end
