Comparing version
@@ -363,5 +363,10 @@ 'use strict'; | ||
// non-object keys, unlike the native `WeakMap`. | ||
// If no makeData function is supplied, the looked-up data will be an empty, | ||
// no-prototype Object. | ||
var defaultMakeData = function () { return Object.create(null); }; | ||
var KeyTrie = /** @class */ (function () { | ||
function KeyTrie(weakness) { | ||
function KeyTrie(weakness, makeData) { | ||
if (makeData === void 0) { makeData = defaultMakeData; } | ||
this.weakness = weakness; | ||
this.makeData = makeData; | ||
} | ||
@@ -378,3 +383,3 @@ KeyTrie.prototype.lookup = function () { | ||
array.forEach(function (key) { return node = node.getChildTrie(key); }); | ||
return node.data || (node.data = Object.create(null)); | ||
return node.data || (node.data = this.makeData(array.slice(0))); | ||
}; | ||
@@ -387,3 +392,3 @@ KeyTrie.prototype.getChildTrie = function (key) { | ||
if (!child) | ||
map.set(key, child = new KeyTrie(this.weakness)); | ||
map.set(key, child = new KeyTrie(this.weakness, this.makeData)); | ||
return child; | ||
@@ -390,0 +395,0 @@ }; |
@@ -360,5 +360,10 @@ import { Slot } from '@wry/context'; | ||
// non-object keys, unlike the native `WeakMap`. | ||
// If no makeData function is supplied, the looked-up data will be an empty, | ||
// no-prototype Object. | ||
var defaultMakeData = function () { return Object.create(null); }; | ||
var KeyTrie = /** @class */ (function () { | ||
function KeyTrie(weakness) { | ||
function KeyTrie(weakness, makeData) { | ||
if (makeData === void 0) { makeData = defaultMakeData; } | ||
this.weakness = weakness; | ||
this.makeData = makeData; | ||
} | ||
@@ -375,3 +380,3 @@ KeyTrie.prototype.lookup = function () { | ||
array.forEach(function (key) { return node = node.getChildTrie(key); }); | ||
return node.data || (node.data = Object.create(null)); | ||
return node.data || (node.data = this.makeData(array.slice(0))); | ||
}; | ||
@@ -384,3 +389,3 @@ KeyTrie.prototype.getChildTrie = function (key) { | ||
if (!child) | ||
map.set(key, child = new KeyTrie(this.weakness)); | ||
map.set(key, child = new KeyTrie(this.weakness, this.makeData)); | ||
return child; | ||
@@ -387,0 +392,0 @@ }; |
@@ -0,7 +1,8 @@ | ||
import { AnyEntry } from "./entry"; | ||
export declare const parentEntrySlot: { | ||
readonly id: string; | ||
hasValue(): boolean; | ||
getValue(): import("./entry").Entry<any, any> | undefined; | ||
withValue<TResult, TArgs extends any[], TThis = any>(value: import("./entry").Entry<any, any>, callback: (this: TThis, ...args: TArgs) => TResult, args?: TArgs | undefined, thisArg?: TThis | undefined): TResult; | ||
getValue(): AnyEntry | undefined; | ||
withValue<TResult, TArgs extends any[], TThis = any>(value: AnyEntry, callback: (this: TThis, ...args: TArgs) => TResult, args?: TArgs | undefined, thisArg?: TThis | undefined): TResult; | ||
}; | ||
export { bind as bindContext, noContext, setTimeout, asyncFromGen, } from "@wry/context"; |
@@ -12,4 +12,4 @@ import { OptimisticWrapOptions } from "./index"; | ||
unsubscribe: Unsubscribable["unsubscribe"]; | ||
readonly parents: Set<Entry<any, any>>; | ||
readonly childValues: Map<Entry<any, any>, Value<any>>; | ||
readonly parents: Set<AnyEntry>; | ||
readonly childValues: Map<AnyEntry, Value<any>>; | ||
dirtyChildren: Set<AnyEntry> | null; | ||
@@ -16,0 +16,0 @@ dirty: boolean; |
export declare class KeyTrie<K> { | ||
private readonly weakness; | ||
private weakness; | ||
private makeData; | ||
private weak?; | ||
private strong?; | ||
private data?; | ||
constructor(weakness: boolean); | ||
constructor(weakness: boolean, makeData?: (array: any[]) => K); | ||
lookup<T extends any[]>(...array: T): K; | ||
@@ -8,0 +9,0 @@ lookupArray<T extends any[]>(array: T): K; |
{ | ||
"name": "optimism", | ||
"version": "0.11.4", | ||
"version": "0.11.5", | ||
"author": "Ben Newman <ben@benjamn.com>", | ||
@@ -37,13 +37,13 @@ "description": "Composable reactive caching with efficient invalidation.", | ||
"devDependencies": { | ||
"@types/mocha": "5.2.7", | ||
"@types/node": "12.7.5", | ||
"fibers": "4.0.1", | ||
"mocha": "6.2.2", | ||
"reify": "0.20.12", | ||
"rimraf": "3.0.0", | ||
"rollup": "1.25.1", | ||
"rollup-plugin-typescript2": "0.24.3", | ||
"source-map-support": "0.5.13", | ||
"tslib": "1.10.0", | ||
"typescript": "3.5.2" | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^13.1.8", | ||
"fibers": "^4.0.3", | ||
"mocha": "^7.0.0", | ||
"reify": "^0.20.12", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^1.29.1", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"source-map-support": "^0.5.16", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -50,0 +50,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
109239
1.72%1093
1.11%