function Rx.take(A)assert(type(A)=="\110\117\109\098\101\114","\066\097\100 \110\117\109\098\101\114")assert(A>0,"\066\097\100 \110\117\109\098\101\114")return function(L)assert(Observable.isObservable(L),"\066\097\100 \111\098\115\101\114\118\097\098\108\101")return Observable.new(function(D)local T=0 local h=Maid.new()h:GiveTask(L:Subscribe(function(...)if T>=A 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 T=T+1 D:Fire(...)if T>=A then D:Complete()end end,D:GetFailComplete()))return h end)end end

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
