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

@dhmk/atom

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dhmk/atom - npm Package Compare versions

Comparing version 2.0.1-test.11 to 2.0.1-test.12

2

esm/atoms/derived.d.ts

@@ -12,2 +12,4 @@ export declare class DerivedAtom {

deps: any;
pit: any;
pt: any;
isObserved: any;

@@ -14,0 +16,0 @@ isEffect: any;

73

esm/atoms/derived.js

@@ -16,2 +16,11 @@ var __assign = (this && this.__assign) || function () {

var call = function (x) { return x(); };
function each(it, fn) {
var x = it.next();
while (!x.done) {
if (fn(x.value) === false)
return false;
x = it.next();
}
return true;
}
var DerivedAtom = /** @class */ (function () {

@@ -30,3 +39,5 @@ function DerivedAtom(fn, isEffect, options) {

this.mark = EID;
this.deps = [];
this.deps = new Map();
this.pit = this.deps.values();
this.pt = this.pit.next().value;
this.isObserved = isEffect;

@@ -55,3 +66,3 @@ this.isEffect = isEffect;

if (state0 <= AtomState.PossiblyStale) {
var ok = this.deps.every(function (t) {
var ok = each(this.deps.values(), function (t) {
var a = t.a;

@@ -67,4 +78,5 @@ a.actualize();

var mark_1 = (this.mark = new Id());
var prevDeps = this.deps;
this.deps = [];
var deps_1 = this.deps;
this.pit = deps_1.values();
this.pt = this.pit.next().value;
if (!this.isObserved && runtime.currentAtom) {

@@ -94,14 +106,6 @@ this.isObserved = true;

runtime.currentAtom = prev;
prevDeps.forEach(function (t) {
var a = t.a;
if (a.m !== mark_1)
removeAtom(a, _this);
a.readFlag = false;
});
this.deps.forEach(function (t) {
var a = t.a;
a.m = t.t;
if (a.readFlag) {
a.readFlag = false;
a.subs.add(_this);
each(deps_1.values(), function (t) {
if (t.m !== mark_1) {
deps_1.delete(t.a);
t.a.subs.delete(_this);
}

@@ -122,14 +126,29 @@ });

DerivedAtom.prototype.track = function (a) {
var am = a.m;
var mark = this.mark;
var vid = a.vid;
var deps = this.deps;
if (am === mark) {
deps[a.ti].v = vid;
var m = this.mark;
var v = a.vid;
if (a.m === m) {
a.ti.v = v;
return;
}
a.m = mark;
a.ti = deps.length;
a.readFlag = true;
deps.push({ a: a, v: vid, t: am }); // literal is faster than class
a.m = m;
var pt = this.pt;
if (pt && pt === a) {
pt.m = m;
pt.v = v;
a.ti = pt;
this.pt = this.pit.next().value;
return;
}
var deps = this.deps;
var t = deps.get(a);
if (!t) {
a.subs.add(this);
t = { a: a, m: m, v: v };
deps.set(a, t);
}
else {
t.m = m;
}
t.v = v;
a.ti = t;
};

@@ -144,3 +163,3 @@ DerivedAtom.prototype.dispose = function () {

this.deps.forEach(function (t) { return removeAtom(t.a, _this); });
this.deps.length = 0;
this.deps.clear();
this.state = AtomState.Stale;

@@ -147,0 +166,0 @@ }

@@ -22,3 +22,3 @@ var __assign = (this && this.__assign) || function () {

this.m = EID;
this.ti = 0;
this.ti = undefined;
this.readFlag = false;

@@ -25,0 +25,0 @@ this.isObserved = false;

@@ -12,2 +12,4 @@ export declare class DerivedAtom {

deps: any;
pit: any;
pt: any;
isObserved: any;

@@ -14,0 +16,0 @@ isEffect: any;

@@ -19,2 +19,11 @@ "use strict";

var call = function (x) { return x(); };
function each(it, fn) {
var x = it.next();
while (!x.done) {
if (fn(x.value) === false)
return false;
x = it.next();
}
return true;
}
var DerivedAtom = /** @class */ (function () {

@@ -33,3 +42,5 @@ function DerivedAtom(fn, isEffect, options) {

this.mark = types_1.EID;
this.deps = [];
this.deps = new Map();
this.pit = this.deps.values();
this.pt = this.pit.next().value;
this.isObserved = isEffect;

@@ -58,3 +69,3 @@ this.isEffect = isEffect;

if (state0 <= types_1.AtomState.PossiblyStale) {
var ok = this.deps.every(function (t) {
var ok = each(this.deps.values(), function (t) {
var a = t.a;

@@ -70,4 +81,5 @@ a.actualize();

var mark_1 = (this.mark = new types_1.Id());
var prevDeps = this.deps;
this.deps = [];
var deps_1 = this.deps;
this.pit = deps_1.values();
this.pt = this.pit.next().value;
if (!this.isObserved && runtime_1.runtime.currentAtom) {

@@ -97,14 +109,6 @@ this.isObserved = true;

runtime_1.runtime.currentAtom = prev;
prevDeps.forEach(function (t) {
var a = t.a;
if (a.m !== mark_1)
(0, shared_1.removeAtom)(a, _this);
a.readFlag = false;
});
this.deps.forEach(function (t) {
var a = t.a;
a.m = t.t;
if (a.readFlag) {
a.readFlag = false;
a.subs.add(_this);
each(deps_1.values(), function (t) {
if (t.m !== mark_1) {
deps_1.delete(t.a);
t.a.subs.delete(_this);
}

@@ -125,14 +129,29 @@ });

DerivedAtom.prototype.track = function (a) {
var am = a.m;
var mark = this.mark;
var vid = a.vid;
var deps = this.deps;
if (am === mark) {
deps[a.ti].v = vid;
var m = this.mark;
var v = a.vid;
if (a.m === m) {
a.ti.v = v;
return;
}
a.m = mark;
a.ti = deps.length;
a.readFlag = true;
deps.push({ a: a, v: vid, t: am }); // literal is faster than class
a.m = m;
var pt = this.pt;
if (pt && pt === a) {
pt.m = m;
pt.v = v;
a.ti = pt;
this.pt = this.pit.next().value;
return;
}
var deps = this.deps;
var t = deps.get(a);
if (!t) {
a.subs.add(this);
t = { a: a, m: m, v: v };
deps.set(a, t);
}
else {
t.m = m;
}
t.v = v;
a.ti = t;
};

@@ -147,3 +166,3 @@ DerivedAtom.prototype.dispose = function () {

this.deps.forEach(function (t) { return (0, shared_1.removeAtom)(t.a, _this); });
this.deps.length = 0;
this.deps.clear();
this.state = types_1.AtomState.Stale;

@@ -150,0 +169,0 @@ }

@@ -25,3 +25,3 @@ "use strict";

this.m = types_1.EID;
this.ti = 0;
this.ti = undefined;
this.readFlag = false;

@@ -28,0 +28,0 @@ this.isObserved = false;

{
"name": "@dhmk/atom",
"version": "2.0.1-test.11",
"version": "2.0.1-test.12",
"description": "Lightweight mobx-like observable values, computed values and side-effects",

@@ -5,0 +5,0 @@ "keywords": [

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