function Promise.prototype.tap(c,L)assert(type(L)=="\102\117\110\099\116\105\111\110",string.format(ERROR_NON_FUNCTION,"\080\114\111\109\105\115\101\058\116\097\112"))return c:_andThen(debug.traceback(nil,2),function(...)local c=L(...)if Promise.is(c)then local L,X=pack(...)return c:andThen(function()return unpack(X,1,L)end)end return...end)end

function Promise.prototype:tap(tapCallback)
	assert(type(tapCallback) == "function", string.format(ERROR_NON_FUNCTION, "Promise:tap"))
	return self:_andThen(debug.traceback(nil, 2), function(...)
		local callbackReturn = tapCallback(...)

		if Promise.is(callbackReturn) then
			local length, values = pack(...)
			return callbackReturn:andThen(function()
				return unpack(values, 1, length)
			end)
		end

		return ...
	end)
end
