New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@urql/exchange-request-policy

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-request-policy - npm Package Compare versions

Comparing version 0.1.5 to 1.0.0

13

CHANGELOG.md
# Changelog
## 1.0.0
### Major Changes
- **Goodbye IE11!** 👋 This major release removes support for IE11. All code that is shipped will be transpiled much less and will _not_ be ES5-compatible anymore, by [@kitten](https://github.com/kitten) (See [#2504](https://github.com/FormidableLabs/urql/pull/2504))
- Upgrade to [Wonka v6](https://github.com/0no-co/wonka) (`wonka@^6.0.0`), which has no breaking changes but is built to target ES2015 and comes with other minor improvements.
The library has fully been migrated to TypeScript which will hopefully help with making contributions easier!, by [@kitten](https://github.com/kitten) (See [#2504](https://github.com/FormidableLabs/urql/pull/2504))
### Patch Changes
- Updated dependencies (See [#2551](https://github.com/FormidableLabs/urql/pull/2551), [#2504](https://github.com/FormidableLabs/urql/pull/2504), [#2619](https://github.com/FormidableLabs/urql/pull/2619), [#2607](https://github.com/FormidableLabs/urql/pull/2607), and [#2504](https://github.com/FormidableLabs/urql/pull/2504))
- @urql/core@3.0.0
## 0.1.5

@@ -4,0 +17,0 @@

77

dist/urql-exchange-request-policy.js

@@ -1,46 +0,49 @@

var e = require("@urql/core");
Object.defineProperty(exports, '__esModule', {
value: true
});
var t = require("wonka");
var core = require('@urql/core');
function _extends() {
return (_extends = Object.assign || function(e) {
for (var t = 1; t < arguments.length; t++) {
var r = arguments[t];
for (var n in r) {
if (Object.prototype.hasOwnProperty.call(r, n)) {
e[n] = r[n];
}
}
var wonka = require('wonka');
const defaultTTL = 5 * 60 * 1000;
const requestPolicyExchange = options => ({
forward
}) => {
const operations = new Map();
const TTL = (options || {}).ttl || defaultTTL;
const processIncomingOperation = operation => {
if (operation.kind !== 'query' || operation.context.requestPolicy !== 'cache-first' && operation.context.requestPolicy !== 'cache-only') {
return operation;
}
return e;
}).apply(this, arguments);
}
exports.requestPolicyExchange = function requestPolicyExchange(r) {
return function(n) {
var o = n.forward;
var c = new Map;
var a = (r || {}).ttl || 3e5;
function processIncomingOperation(t) {
if ("query" !== t.kind || "cache-first" !== t.context.requestPolicy && "cache-only" !== t.context.requestPolicy) {
return t;
}
if ((new Date).getTime() - (c.get(t.key) || 0) > a && (!r.shouldUpgrade || r.shouldUpgrade(t))) {
return e.makeOperation(t.kind, t, _extends({}, t.context, {
requestPolicy: "cache-and-network"
}));
}
return t;
const currentTime = new Date().getTime();
const lastOccurrence = operations.get(operation.key) || 0;
if (currentTime - lastOccurrence > TTL && (!options.shouldUpgrade || options.shouldUpgrade(operation))) {
return core.makeOperation(operation.kind, operation, { ...operation.context,
requestPolicy: 'cache-and-network'
});
}
function processIncomingResults(e) {
var t = e.operation.context.meta;
if (!t || "miss" === t.cacheOutcome) {
c.set(e.operation.key, (new Date).getTime());
}
return operation;
};
const processIncomingResults = result => {
const meta = result.operation.context.meta;
const isMiss = !meta || meta.cacheOutcome === 'miss';
if (isMiss) {
operations.set(result.operation.key, new Date().getTime());
}
return function(e) {
return t.tap(processIncomingResults)(o(t.map(processIncomingOperation)(e)));
};
};
return ops$ => {
return wonka.tap(processIncomingResults)(forward(wonka.map(processIncomingOperation)(ops$)));
};
};
exports.requestPolicyExchange = requestPolicyExchange;
//# sourceMappingURL=urql-exchange-request-policy.js.map

@@ -1,2 +0,2 @@

var e=require("@urql/core"),t=require("wonka");function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}exports.requestPolicyExchange=function(n){return function(o){var a=o.forward,c=new Map,i=(n||{}).ttl||3e5;function u(t){return"query"!==t.kind||"cache-first"!==t.context.requestPolicy&&"cache-only"!==t.context.requestPolicy?t:(new Date).getTime()-(c.get(t.key)||0)>i&&(!n.shouldUpgrade||n.shouldUpgrade(t))?e.makeOperation(t.kind,t,r({},t.context,{requestPolicy:"cache-and-network"})):t}function s(e){var t=e.operation.context.meta;(!t||"miss"===t.cacheOutcome)&&c.set(e.operation.key,(new Date).getTime())}return function(e){return t.tap(s)(a(t.map(u)(e)))}}};
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@urql/core"),t=require("wonka");exports.requestPolicyExchange=o=>({forward:r})=>{const a=new Map,c=(o||{}).ttl||3e5,n=t=>"query"!==t.kind||"cache-first"!==t.context.requestPolicy&&"cache-only"!==t.context.requestPolicy?t:(new Date).getTime()-(a.get(t.key)||0)>c&&(!o.shouldUpgrade||o.shouldUpgrade(t))?e.makeOperation(t.kind,t,{...t.context,requestPolicy:"cache-and-network"}):t,i=e=>{const t=e.operation.context.meta;(!t||"miss"===t.cacheOutcome)&&a.set(e.operation.key,(new Date).getTime())};return e=>t.tap(i)(r(t.map(n)(e)))};
//# sourceMappingURL=urql-exchange-request-policy.min.js.map
{
"name": "@urql/exchange-request-policy",
"version": "0.1.5",
"version": "1.0.0",
"description": "An exchange for operation request-policy upgrading in urql",

@@ -59,4 +59,4 @@ "sideEffects": false,

"dependencies": {
"@urql/core": ">=2.3.6",
"wonka": "^4.0.14"
"@urql/core": ">=3.0.0",
"wonka": "^6.0.0"
},

@@ -63,0 +63,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc