%PDF- %PDF-
Direktori : /var/www/html/node_modules/swr/immutable/dist/ |
Current File : /var/www/html/node_modules/swr/immutable/dist/index.js |
Object.defineProperty(exports, '__esModule', { value: true }); var useSWR = require('swr'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var useSWR__default = /*#__PURE__*/_interopDefaultLegacy(useSWR); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var isFunction = function (v) { return typeof v == 'function'; }; var normalize = function (args) { return isFunction(args[1]) ? [args[0], args[1], args[2] || {}] : [args[0], null, (args[1] === null ? args[2] : args[1]) || {}]; }; // Create a custom hook with a middleware var withMiddleware = function (useSWR, middleware) { return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var _a = normalize(args), key = _a[0], fn = _a[1], config = _a[2]; var uses = (config.use || []).concat(middleware); return useSWR(key, fn, __assign(__assign({}, config), { use: uses })); }; }; var immutable = function (useSWRNext) { return function (key, fetcher, config) { // Always override all revalidate options. config.revalidateOnFocus = false; config.revalidateIfStale = false; config.revalidateOnReconnect = false; return useSWRNext(key, fetcher, config); }; }; var index = withMiddleware(useSWR__default['default'], immutable); exports['default'] = index; exports.immutable = immutable;