From 6bd79261b8794713aac57feb630b206f5bd1f80e Mon Sep 17 00:00:00 2001 From: hazae41 Date: Sun, 4 Sep 2022 14:59:11 +0200 Subject: [PATCH] bump --- dist/index.esm.js | 4 ++++ dist/index.js | 4 ++++ package.json | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dist/index.esm.js b/dist/index.esm.js index d6e1f31a..e21f2b2b 100644 --- a/dist/index.esm.js +++ b/dist/index.esm.js @@ -1051,18 +1051,22 @@ var Core = /** @class */ (function (_super) { return [2 /*return*/]; case 2: next = __assign({ time: Date.now(), data: current === null || current === void 0 ? void 0 : current.data, error: current === null || current === void 0 ? void 0 : current.error, cooldown: current === null || current === void 0 ? void 0 : current.cooldown, expiration: current === null || current === void 0 ? void 0 : current.expiration, aborter: current === null || current === void 0 ? void 0 : current.aborter }, state); + // Force prevent requests from mutating the aborter if it's not their own if (aborter) next.aborter = aborter === (current === null || current === void 0 ? void 0 : current.aborter) ? state.aborter : current === null || current === void 0 ? void 0 : current.aborter; + // Keep the current state if the new state is older if (next.time !== undefined && next.time < ((_a = current === null || current === void 0 ? void 0 : current.time) !== null && _a !== void 0 ? _a : 0)) { next.time = current === null || current === void 0 ? void 0 : current.time; next.data = current === null || current === void 0 ? void 0 : current.data; next.error = current === null || current === void 0 ? void 0 : current.error; } _b = params.equals, equals = _b === void 0 ? DEFAULT_EQUALS : _b; + // Prevent some renders if the data is the same if (equals(next.data, current === null || current === void 0 ? void 0 : current.data)) next.data = current === null || current === void 0 ? void 0 : current.data; + // Shallow comparison because aborter is not serializable if (shallowEquals(next, current)) return [2 /*return*/, current]; return [4 /*yield*/, this.set(skey, next, params)]; diff --git a/dist/index.js b/dist/index.js index 99947835..43657b9f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1057,18 +1057,22 @@ var Core = /** @class */ (function (_super) { return [2 /*return*/]; case 2: next = __assign({ time: Date.now(), data: current === null || current === void 0 ? void 0 : current.data, error: current === null || current === void 0 ? void 0 : current.error, cooldown: current === null || current === void 0 ? void 0 : current.cooldown, expiration: current === null || current === void 0 ? void 0 : current.expiration, aborter: current === null || current === void 0 ? void 0 : current.aborter }, state); + // Force prevent requests from mutating the aborter if it's not their own if (aborter) next.aborter = aborter === (current === null || current === void 0 ? void 0 : current.aborter) ? state.aborter : current === null || current === void 0 ? void 0 : current.aborter; + // Keep the current state if the new state is older if (next.time !== undefined && next.time < ((_a = current === null || current === void 0 ? void 0 : current.time) !== null && _a !== void 0 ? _a : 0)) { next.time = current === null || current === void 0 ? void 0 : current.time; next.data = current === null || current === void 0 ? void 0 : current.data; next.error = current === null || current === void 0 ? void 0 : current.error; } _b = params.equals, equals = _b === void 0 ? DEFAULT_EQUALS : _b; + // Prevent some renders if the data is the same if (equals(next.data, current === null || current === void 0 ? void 0 : current.data)) next.data = current === null || current === void 0 ? void 0 : current.data; + // Shallow comparison because aborter is not serializable if (shallowEquals(next, current)) return [2 /*return*/, current]; return [4 /*yield*/, this.set(skey, next, params)]; diff --git a/package.json b/package.json index 5938346e..45f30e99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hazae41/xswr", - "version": "1.0.56", + "version": "1.0.57", "author": "hazae41", "license": "MIT", "description": "The simplest React data (re)fetching library ever made",