Comparing version 0.8.1 to 0.8.2
@@ -398,9 +398,4 @@ function defaultDispose() { } | ||
var KeyTrie = /** @class */ (function () { | ||
function KeyTrie() { | ||
// Since a `WeakMap` cannot hold primitive values as keys, we need a | ||
// backup `Map` instance to hold primitive keys. Both `this._weakMap` | ||
// and `this._strongMap` are lazily initialized. | ||
this.weak = null; | ||
this.strong = null; | ||
this.data = null; | ||
function KeyTrie(weakness) { | ||
this.weakness = weakness; | ||
} | ||
@@ -413,3 +408,3 @@ KeyTrie.prototype.lookup = function (tuple) { | ||
KeyTrie.prototype.getChildTrie = function (key) { | ||
var map = isObjRef(key) | ||
var map = this.weakness && isObjRef(key) | ||
? this.weak || (this.weak = new WeakMap()) | ||
@@ -419,3 +414,3 @@ : this.strong || (this.strong = new Map()); | ||
if (!child) | ||
map.set(key, child = new KeyTrie()); | ||
map.set(key, child = new KeyTrie(this.weakness)); | ||
return child; | ||
@@ -444,3 +439,3 @@ }; | ||
// In those cases, just write your own custom makeCacheKey functions. | ||
var keyTrie = new KeyTrie(); | ||
var keyTrie = new KeyTrie(true); | ||
function defaultMakeCacheKey() { | ||
@@ -516,3 +511,3 @@ var args = []; | ||
export { defaultMakeCacheKey, wrap }; | ||
export { defaultMakeCacheKey, KeyTrie, wrap }; | ||
//# sourceMappingURL=bundle.esm.js.map |
@@ -0,3 +1,5 @@ | ||
import { KeyTrie } from "./key-trie"; | ||
export declare type TCacheKey = any; | ||
export declare function defaultMakeCacheKey(...args: any[]): any; | ||
export { KeyTrie }; | ||
export declare type OptimisticWrapperFunction<TArgs extends any[], TResult> = ((...args: TArgs) => TResult) & { | ||
@@ -4,0 +6,0 @@ dirty: (...args: TArgs) => void; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var key_trie_1 = require("./key-trie"); | ||
exports.KeyTrie = key_trie_1.KeyTrie; | ||
// The defaultMakeCacheKey function is remarkably powerful, because it gives | ||
@@ -15,3 +16,3 @@ // a unique object for any shallow-identical list of arguments. If you need | ||
// In those cases, just write your own custom makeCacheKey functions. | ||
var keyTrie = new key_trie_1.KeyTrie(); | ||
var keyTrie = new key_trie_1.KeyTrie(true); | ||
function defaultMakeCacheKey() { | ||
@@ -18,0 +19,0 @@ var args = []; |
export declare class KeyTrie<K> { | ||
private weak; | ||
private strong; | ||
private data; | ||
private readonly weakness; | ||
private weak?; | ||
private strong?; | ||
private data?; | ||
constructor(weakness: boolean); | ||
lookup<T extends any[]>(tuple: T): K; | ||
private getChildTrie; | ||
} |
@@ -6,9 +6,4 @@ "use strict"; | ||
var KeyTrie = /** @class */ (function () { | ||
function KeyTrie() { | ||
// Since a `WeakMap` cannot hold primitive values as keys, we need a | ||
// backup `Map` instance to hold primitive keys. Both `this._weakMap` | ||
// and `this._strongMap` are lazily initialized. | ||
this.weak = null; | ||
this.strong = null; | ||
this.data = null; | ||
function KeyTrie(weakness) { | ||
this.weakness = weakness; | ||
} | ||
@@ -21,3 +16,3 @@ KeyTrie.prototype.lookup = function (tuple) { | ||
KeyTrie.prototype.getChildTrie = function (key) { | ||
var map = isObjRef(key) | ||
var map = this.weakness && isObjRef(key) | ||
? this.weak || (this.weak = new WeakMap()) | ||
@@ -27,3 +22,3 @@ : this.strong || (this.strong = new Map()); | ||
if (!child) | ||
map.set(key, child = new KeyTrie()); | ||
map.set(key, child = new KeyTrie(this.weakness)); | ||
return child; | ||
@@ -30,0 +25,0 @@ }; |
{ | ||
"name": "optimism", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90301
1088