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.13.0 to 0.13.1

32

lib/bundle.cjs.js

@@ -133,5 +133,4 @@ 'use strict';

var Entry = /** @class */ (function () {
function Entry(fn, args) {
function Entry(fn) {
this.fn = fn;
this.args = args;
this.parents = new Set();

@@ -160,7 +159,7 @@ this.childValues = new Map();

// (3) valueGet(this.value) is usually returned without recomputation.
Entry.prototype.recompute = function () {
Entry.prototype.recompute = function (args) {
assert(!this.recomputing, "already recomputing");
rememberParent(this);
return mightBeDirty(this)
? reallyRecompute(this)
? reallyRecompute(this, args)
: valueGet(this.value);

@@ -235,7 +234,7 @@ };

}
function reallyRecompute(entry) {
function reallyRecompute(entry, args) {
forgetChildren(entry);
// Set entry as the parent entry while calling recomputeNewValue(entry).
parentEntrySlot.withValue(entry, recomputeNewValue, [entry]);
if (maybeSubscribe(entry)) {
parentEntrySlot.withValue(entry, recomputeNewValue, [entry, args]);
if (maybeSubscribe(entry, args)) {
// If we successfully recomputed entry.value and did not fail to

@@ -247,3 +246,3 @@ // (re)subscribe, then this Entry is no longer explicitly dirty.

}
function recomputeNewValue(entry) {
function recomputeNewValue(entry, args) {
entry.recomputing = true;

@@ -254,3 +253,3 @@ // Set entry.value as unknown.

// If entry.fn succeeds, entry.value will become a normal Value.
entry.value[0] = entry.fn.apply(null, entry.args);
entry.value[0] = entry.fn.apply(null, args);
}

@@ -351,7 +350,7 @@ catch (e) {

}
function maybeSubscribe(entry) {
function maybeSubscribe(entry, args) {
if (typeof entry.subscribe === "function") {
try {
maybeUnsubscribe(entry); // Prevent double subscriptions.
entry.unsubscribe = entry.subscribe.apply(null, entry.args);
entry.unsubscribe = entry.subscribe.apply(null, args);
}

@@ -480,13 +479,8 @@ catch (e) {

}
var args = Array.prototype.slice.call(arguments);
var entry = cache.get(key);
if (entry) {
entry.args = args;
}
else {
entry = new Entry(originalFunction, args);
cache.set(key, entry);
if (!entry) {
cache.set(key, entry = new Entry(originalFunction));
entry.subscribe = options.subscribe;
}
var value = entry.recompute();
var value = entry.recompute(Array.prototype.slice.call(arguments));
// Move this entry to the front of the least-recently used queue,

@@ -493,0 +487,0 @@ // since we just finished computing its value.

@@ -130,5 +130,4 @@ import { Slot } from '@wry/context';

var Entry = /** @class */ (function () {
function Entry(fn, args) {
function Entry(fn) {
this.fn = fn;
this.args = args;
this.parents = new Set();

@@ -157,7 +156,7 @@ this.childValues = new Map();

// (3) valueGet(this.value) is usually returned without recomputation.
Entry.prototype.recompute = function () {
Entry.prototype.recompute = function (args) {
assert(!this.recomputing, "already recomputing");
rememberParent(this);
return mightBeDirty(this)
? reallyRecompute(this)
? reallyRecompute(this, args)
: valueGet(this.value);

@@ -232,7 +231,7 @@ };

}
function reallyRecompute(entry) {
function reallyRecompute(entry, args) {
forgetChildren(entry);
// Set entry as the parent entry while calling recomputeNewValue(entry).
parentEntrySlot.withValue(entry, recomputeNewValue, [entry]);
if (maybeSubscribe(entry)) {
parentEntrySlot.withValue(entry, recomputeNewValue, [entry, args]);
if (maybeSubscribe(entry, args)) {
// If we successfully recomputed entry.value and did not fail to

@@ -244,3 +243,3 @@ // (re)subscribe, then this Entry is no longer explicitly dirty.

}
function recomputeNewValue(entry) {
function recomputeNewValue(entry, args) {
entry.recomputing = true;

@@ -251,3 +250,3 @@ // Set entry.value as unknown.

// If entry.fn succeeds, entry.value will become a normal Value.
entry.value[0] = entry.fn.apply(null, entry.args);
entry.value[0] = entry.fn.apply(null, args);
}

@@ -348,7 +347,7 @@ catch (e) {

}
function maybeSubscribe(entry) {
function maybeSubscribe(entry, args) {
if (typeof entry.subscribe === "function") {
try {
maybeUnsubscribe(entry); // Prevent double subscriptions.
entry.unsubscribe = entry.subscribe.apply(null, entry.args);
entry.unsubscribe = entry.subscribe.apply(null, args);
}

@@ -477,13 +476,8 @@ catch (e) {

}
var args = Array.prototype.slice.call(arguments);
var entry = cache.get(key);
if (entry) {
entry.args = args;
}
else {
entry = new Entry(originalFunction, args);
cache.set(key, entry);
if (!entry) {
cache.set(key, entry = new Entry(originalFunction));
entry.subscribe = options.subscribe;
}
var value = entry.recompute();
var value = entry.recompute(Array.prototype.slice.call(arguments));
// Move this entry to the front of the least-recently used queue,

@@ -490,0 +484,0 @@ // since we just finished computing its value.

@@ -8,3 +8,2 @@ import { OptimisticWrapOptions } from "./index";

readonly fn: (...args: TArgs) => TValue;
args: TArgs;
static count: number;

@@ -19,5 +18,5 @@ subscribe: OptimisticWrapOptions<TArgs>["subscribe"];

readonly value: Value<TValue>;
constructor(fn: (...args: TArgs) => TValue, args: TArgs);
constructor(fn: (...args: TArgs) => TValue);
peek(): TValue | undefined;
recompute(): TValue;
recompute(args: TArgs): TValue;
setDirty(): void;

@@ -24,0 +23,0 @@ dispose(): void;

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

@@ -44,3 +44,3 @@ "description": "Composable reactive caching with efficient invalidation.",

"rollup": "^2.9.1",
"rollup-plugin-typescript2": "^0.27.0",
"rollup-plugin-typescript2": "^0.29.0",
"source-map-support": "^0.5.19",

@@ -47,0 +47,0 @@ "tslib": "^1.11.2",

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