UNPKG

react-query

Version:

Hooks for managing, caching and syncing asynchronous and remote data in React

3 lines (2 loc) 1.74 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).ReactQueryCreateWebStoragePersistorExperimental={})}(this,(function(t){"use strict";function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function r(){}function n(t,e){void 0===e&&(e=100);var r,n=null;return function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];r=o,null===n&&(n=setTimeout((function(){t.apply(void 0,r),n=null}),e))}}t.createWebStoragePersistor=function(t){var i=t.storage,o=t.key,a=void 0===o?"REACT_QUERY_OFFLINE_CACHE":o,u=t.throttleTime,f=void 0===u?1e3:u,s=t.serialize,c=void 0===s?JSON.stringify:s,l=t.deserialize,d=void 0===l?JSON.parse:l;function v(t){try{i.setItem(a,c(t))}catch(t){return!1}return!0}return void 0!==i?{persistClient:n((function(t){if(!0!==v(t)){for(var r=[].concat(t.clientState.mutations),n=[].concat(t.clientState.queries),i=e({},t,{clientState:{mutations:r,queries:n}}),o=[].concat(n).sort((function(t,e){return t.state.dataUpdatedAt-e.state.dataUpdatedAt})),a=function(){var t=o.shift();if(i.clientState.queries=n.filter((function(e){return e!==t})),v(i))return{v:void 0}};o.length>0;){var u=a();if("object"==typeof u)return u.v}for(;r.shift();)if(v(i))return}}),f),restoreClient:function(){var t=i.getItem(a);if(t)return d(t)},removeClient:function(){i.removeItem(a)}}:{persistClient:r,restoreClient:r,removeClient:r}},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=createWebStoragePersistor-experimental.production.min.js.map