local O={}O.__index=O local g=require(script.Parent.MockDataStoreManager)local Y=require(script.Parent.MockDataStoreUtils)function O.GetCurrentPage(O)local g={}local Y=math.max(1,(O.__currentPage-1)*O.__pageSize+1)local M=math.min(O.__currentPage*O.__pageSize,#O.__results)for Y=Y,M,1 do table.insert(g,{key=O.__results[Y].key,value=O.__results[Y].value})end return g end function O.AdvanceToNextPageAsync(O)if O.IsFinished then error("\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099 \114\101\106\101\099\116\101\100 \119\105\116\104 \101\114\114\111\114 \040\110\111 \112\097\103\101\115 \116\111 \097\100\118\097\110\099\101 \116\111\041",2)end Y.simulateErrorCheck("\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099")local M=g.YieldForBudget(function()warn("\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099 \114\101\113\117\101\115\116 \119\097\115 \116\104\114\111\116\116\108\101\100 \100\117\101 \116\111 \108\097\099\107 \111\102 \098\117\100\103\101\116\046 \084\114\121 \115\101\110\100\105\110\103 \102\101\119\101\114 \114\101\113\117\101\115\116\115\046")end,{Enum.DataStoreRequestType.GetAsync})if not M then error("\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099 \114\101\106\101\099\116\101\100 \119\105\116\104 \101\114\114\111\114 \040\114\101\113\117\101\115\116 \119\097\115 \116\104\114\111\116\116\108\101\100\044 \098\117\116 \116\104\114\111\116\116\108\101\100 \113\117\101\117\101 \119\097\115 \102\117\108\108\041",2)end Y.simulateYield()if#O.__results>O.__currentPage*O.__pageSize then O.__currentPage=O.__currentPage+1 end O.IsFinished=#O.__results<=O.__currentPage*O.__pageSize Y.logMethod(O.__datastore,"\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099")end return O
--[[
	MockDataStorePages.lua
	This module implements the API and functionality of Roblox's DataStorePages class.

	This module is licensed under APLv2, refer to the LICENSE file or:
	buildthomas/MockDataStoreService/blob/master/LICENSE
]]

local MockDataStorePages = {}
MockDataStorePages.__index = MockDataStorePages

local MockDataStoreManager = require(script.Parent.MockDataStoreManager)
local Utils = require(script.Parent.MockDataStoreUtils)

function MockDataStorePages:GetCurrentPage()
	local retValue = {}

	local minimumIndex = math.max(1, (self.__currentPage - 1) * self.__pageSize + 1)
	local maximumIndex = math.min(self.__currentPage * self.__pageSize, #self.__results)
	for i = minimumIndex, maximumIndex do
		table.insert(retValue, {key = self.__results[i].key, value = self.__results[i].value})
	end

	return retValue
end

function MockDataStorePages:AdvanceToNextPageAsync()
	if self.IsFinished then
		error("AdvanceToNextPageAsync rejected with error (no pages to advance to)", 2)
	end

	Utils.simulateErrorCheck("AdvanceToNextPageAsync")

	local success = MockDataStoreManager.YieldForBudget(
		function()
			warn("AdvanceToNextPageAsync request was throttled due to lack of budget. Try sending fewer requests.")
		end,
		{Enum.DataStoreRequestType.GetAsync}
	)

	if not success then
		error("AdvanceToNextPageAsync rejected with error (request was throttled, but throttled queue was full)", 2)
	end

	Utils.simulateYield()

	if #self.__results > self.__currentPage * self.__pageSize then
		self.__currentPage = self.__currentPage + 1
	end
	self.IsFinished = #self.__results <= self.__currentPage * self.__pageSize

	Utils.logMethod(self.__datastore, "AdvanceToNextPageAsync")

end

return MockDataStorePages
