Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

optimism

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimism - npm Package Compare versions

Comparing version 0.14.0 to 0.14.1

74

lib/bundle.cjs.js

@@ -23,9 +23,9 @@ 'use strict';

Cache.prototype.get = function (key) {
var entry = this.getEntry(key);
return entry && entry.value;
var node = this.getNode(key);
return node && node.value;
};
Cache.prototype.getEntry = function (key) {
var entry = this.map.get(key);
if (entry && entry !== this.newest) {
var older = entry.older, newer = entry.newer;
Cache.prototype.getNode = function (key) {
var node = this.map.get(key);
if (node && node !== this.newest) {
var older = node.older, newer = node.newer;
if (newer) {

@@ -37,18 +37,18 @@ newer.older = older;

}
entry.older = this.newest;
entry.older.newer = entry;
entry.newer = null;
this.newest = entry;
if (entry === this.oldest) {
node.older = this.newest;
node.older.newer = node;
node.newer = null;
this.newest = node;
if (node === this.oldest) {
this.oldest = newer;
}
}
return entry;
return node;
};
Cache.prototype.set = function (key, value) {
var entry = this.getEntry(key);
if (entry) {
return entry.value = value;
var node = this.getNode(key);
if (node) {
return node.value = value;
}
entry = {
node = {
key: key,

@@ -60,8 +60,8 @@ value: value,

if (this.newest) {
this.newest.newer = entry;
this.newest.newer = node;
}
this.newest = entry;
this.oldest = this.oldest || entry;
this.map.set(key, entry);
return entry.value;
this.newest = node;
this.oldest = this.oldest || node;
this.map.set(key, node);
return node.value;
};

@@ -74,18 +74,18 @@ Cache.prototype.clean = function () {

Cache.prototype.delete = function (key) {
var entry = this.map.get(key);
if (entry) {
if (entry === this.newest) {
this.newest = entry.older;
var node = this.map.get(key);
if (node) {
if (node === this.newest) {
this.newest = node.older;
}
if (entry === this.oldest) {
this.oldest = entry.newer;
if (node === this.oldest) {
this.oldest = node.newer;
}
if (entry.newer) {
entry.newer.older = entry.older;
if (node.newer) {
node.newer.older = node.older;
}
if (entry.older) {
entry.older.newer = entry.newer;
if (node.older) {
node.older.newer = node.newer;
}
this.map.delete(key);
this.dispose(entry.value, key);
this.dispose(node.value, key);
return true;

@@ -417,12 +417,6 @@ }

var cache = new Cache(options.max || Math.pow(2, 16), function (entry) { return entry.dispose(); });
var keyArgs = options.keyArgs || (function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return args;
});
var keyArgs = options.keyArgs;
var makeCacheKey = options.makeCacheKey || defaultMakeCacheKey;
function optimistic() {
var key = makeCacheKey.apply(null, keyArgs.apply(null, arguments));
var key = makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments);
if (key === void 0) {

@@ -429,0 +423,0 @@ return originalFunction.apply(null, arguments);

@@ -21,9 +21,9 @@ import { Trie } from '@wry/trie';

Cache.prototype.get = function (key) {
var entry = this.getEntry(key);
return entry && entry.value;
var node = this.getNode(key);
return node && node.value;
};
Cache.prototype.getEntry = function (key) {
var entry = this.map.get(key);
if (entry && entry !== this.newest) {
var older = entry.older, newer = entry.newer;
Cache.prototype.getNode = function (key) {
var node = this.map.get(key);
if (node && node !== this.newest) {
var older = node.older, newer = node.newer;
if (newer) {

@@ -35,18 +35,18 @@ newer.older = older;

}
entry.older = this.newest;
entry.older.newer = entry;
entry.newer = null;
this.newest = entry;
if (entry === this.oldest) {
node.older = this.newest;
node.older.newer = node;
node.newer = null;
this.newest = node;
if (node === this.oldest) {
this.oldest = newer;
}
}
return entry;
return node;
};
Cache.prototype.set = function (key, value) {
var entry = this.getEntry(key);
if (entry) {
return entry.value = value;
var node = this.getNode(key);
if (node) {
return node.value = value;
}
entry = {
node = {
key: key,

@@ -58,8 +58,8 @@ value: value,

if (this.newest) {
this.newest.newer = entry;
this.newest.newer = node;
}
this.newest = entry;
this.oldest = this.oldest || entry;
this.map.set(key, entry);
return entry.value;
this.newest = node;
this.oldest = this.oldest || node;
this.map.set(key, node);
return node.value;
};

@@ -72,18 +72,18 @@ Cache.prototype.clean = function () {

Cache.prototype.delete = function (key) {
var entry = this.map.get(key);
if (entry) {
if (entry === this.newest) {
this.newest = entry.older;
var node = this.map.get(key);
if (node) {
if (node === this.newest) {
this.newest = node.older;
}
if (entry === this.oldest) {
this.oldest = entry.newer;
if (node === this.oldest) {
this.oldest = node.newer;
}
if (entry.newer) {
entry.newer.older = entry.older;
if (node.newer) {
node.newer.older = node.older;
}
if (entry.older) {
entry.older.newer = entry.newer;
if (node.older) {
node.older.newer = node.newer;
}
this.map.delete(key);
this.dispose(entry.value, key);
this.dispose(node.value, key);
return true;

@@ -415,12 +415,6 @@ }

var cache = new Cache(options.max || Math.pow(2, 16), function (entry) { return entry.dispose(); });
var keyArgs = options.keyArgs || (function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return args;
});
var keyArgs = options.keyArgs;
var makeCacheKey = options.makeCacheKey || defaultMakeCacheKey;
function optimistic() {
var key = makeCacheKey.apply(null, keyArgs.apply(null, arguments));
var key = makeCacheKey.apply(null, keyArgs ? keyArgs.apply(null, arguments) : arguments);
if (key === void 0) {

@@ -427,0 +421,0 @@ return originalFunction.apply(null, arguments);

@@ -10,3 +10,3 @@ export declare class Cache<K = any, V = any> {

get(key: K): V | undefined;
private getEntry;
private getNode;
set(key: K, value: V): V;

@@ -13,0 +13,0 @@ clean(): void;

{
"name": "optimism",
"version": "0.14.0",
"version": "0.14.1",
"author": "Ben Newman <ben@benjamn.com>",

@@ -5,0 +5,0 @@ "description": "Composable reactive caching with efficient invalidation.",

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