import e from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/regenerator";import{corvaDataAPI as o}from"../../../../../clients/index.js";function i(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var p=function(){var r=t(n.mark((function r(t){var i,p,c,s,u,l,f,b,m,g,h,y,O,v,d,j,w,P,S,k;return n.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:i=t.path,p=t.queryParams,c=t.chunkSize,s=void 0===c?1e3:c,u=t.fetchLimit,l=void 0===u?1/0:u,f=t.signal,b=t.paginationStyle,m=void 0===b?"offset":b,g=t.fetcher,h=void 0===g?o.get:g,y=t.rawQueryString,O=[],v=[],j=1;case 4:return null==f||f.throwIfAborted(),S=l-O.length,d=Math.min(s,S),k="offset"===m?{limit:d,skip:O.length}:{per_page:d,page:j},r.next=10,h(i,a(a({},p),k),{signal:f,rawQueryString:y});case 10:v=r.sent,O.push.apply(O,e(null!==(P=v)&&void 0!==P?P:[])),j+=1;case 13:if(O.length<l&&(null===(w=v)||void 0===w?void 0:w.length)>0&&v.length===d){r.next=4;break}case 14:return r.abrupt("return",O);case 15:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();export{p as fetchDataByChunks};
//# sourceMappingURL=fetchDataByChunks.js.map
