Comparing version 0.2.0 to 0.2.1
@@ -11,4 +11,5 @@ "use strict"; | ||
function wrap(fn, options) { | ||
function normalizeOptions(options) { | ||
options = options || Object.create(null); | ||
if (typeof options.makeCacheKey !== "function") { | ||
@@ -18,5 +19,18 @@ options.makeCacheKey = defaultMakeCacheKey; | ||
if (typeof options.max !== "number") { | ||
options.max = Math.pow(2, 16); | ||
} | ||
return options; | ||
} | ||
function wrap(fn, options) { | ||
options = normalizeOptions(options); | ||
var cache = new LRU({ | ||
dispose: function (entry, key) { | ||
// TODO | ||
max: options.max, | ||
dispose: function (key, entry) { | ||
if (typeof entry.unsubscribe === "function") { | ||
entry.unsubscribe.call(optimistic); | ||
} | ||
} | ||
@@ -37,2 +51,5 @@ }); | ||
cache.set(key, entry = new Entry(fn, key, args)); | ||
if (typeof options.subscribe === "function") { | ||
entry.unsubscribe = options.subscribe.apply(optimistic, args); | ||
} | ||
} | ||
@@ -39,0 +56,0 @@ |
{ | ||
"name": "optimism", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Ben Newman <ben@benjamn.com>", | ||
@@ -5,0 +5,0 @@ "description": "Composable reactive caching with efficient invalidation.", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8050
188
0