local H=require(script.Parent.MockDataStoreManager)local k=require(script.Parent.MockDataStoreUtils)local F={}F.__index=F function F.GetCurrentPage(H)local k={}local F=math.max(1,(H.__currentPage-1)*H.__pageSize+1)local u=math.min(H.__currentPage*H.__pageSize,#H.__results)for F=F,u,1 do table.insert(k,{key=H.__results[F].key;value=H.__results[F].value})end return k end function F.AdvanceToNextPageAsync(F)if F.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 k.simulateErrorCheck("\065\100\118\097\110\099\101\084\111\078\101\120\116\080\097\103\101\065\115\121\110\099")local u=H.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,table.create(1,Enum.DataStoreRequestType.GetAsync))if not u 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 k.simulateYield()if#F.__results>F.__currentPage*F.__pageSize then F.__currentPage+=1 end F.IsFinished=#F.__results<=F.__currentPage*F.__pageSize k.logMethod(F.__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 F
--[[
	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:
	https://github.com/buildthomas/MockDataStoreService/blob/master/LICENSE
]]

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

local MockDataStorePages = {}
MockDataStorePages.__index = MockDataStorePages

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, table.create(1, 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 += 1
	end

	self.IsFinished = #self.__results <= self.__currentPage * self.__pageSize
	Utils.logMethod(self.__datastore, "AdvanceToNextPageAsync")
end

return MockDataStorePages
