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.6 to 2.0.1-test.7

73

esm/atoms/derived.js

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

DerivedAtom.prototype.actualize = function () {
var _this = this;
if (this.state === 1 || this.state === 2) {
this.recalc = false;
var deps = this.deps, i = deps.length, t = void 0, a = void 0;
while (i--) {
t = deps[i];
a = t.a;
var ok = this.deps.every(function (t) {
var a = t.a;
a.actualize();
if (a.vid !== t.v) {
this.state = 3;
break;
}
}
// const ok = eachar(this.deps, (t) => {
// const a = t.a;
// a.actualize();
// return a.vid === t.v;
// });
// if (!ok) this.state = 3;
return a.vid === t.v;
});
if (!ok)
this.state = 3;
}
if (this.state === 3) {
var mark = (this.mark = new Id());
var mark_1 = (this.mark = new Id());
var prevDeps = this.deps;
this.deps = new Array(prevDeps.length || 10);
this.deps = [];
this.pdi = 0;

@@ -76,35 +67,17 @@ if (!this.isObserved && runtime.currentAtom) {

// temp hack
if (this.deps.length)
this.deps.length = this.pdi;
var deps = prevDeps, i = deps.length, t = void 0, a = void 0;
while (i--) {
a = deps[i].a;
if (a.m !== mark)
removeAtom(a, this);
// if (this.deps.length) this.deps.length = this.pdi;
prevDeps.forEach(function (t) {
var a = t.a;
if (a.m !== mark_1)
removeAtom(a, _this);
a.readFlag = false;
}
// eacha(prevDeps, (t) => {
// const a = t.a;
// if (a.m !== mark) removeAtom(a, this);
// a.readFlag = 0;
// });
deps = this.deps;
i = deps.length;
while (i--) {
t = deps[i];
a = t.a;
});
this.deps.forEach(function (t) {
var a = t.a;
a.m = t.t;
if (a.readFlag) {
a.readFlag = false;
a.subs.add(this);
a.subs.add(_this);
}
}
// eacha(this.deps, (t) => {
// const a = t.a;
// a.m = t.t;
// if (a.readFlag) {
// a.readFlag = 0;
// a.subs.add(this);
// }
// });
});
if (!this.options.equals(nextValue, this.value)) {

@@ -130,5 +103,5 @@ this.value = nextValue;

}
var ti = this.pdi++;
deps[ti] = { a: a, v: vid, t: am }; // literal is faster than class
// deps.push({ a, v: vid, t: am });
var ti = deps.length; // this.pdi++;
// deps[ti] = { a, v: vid, t: am }; // literal is faster than class
deps.push({ a: a, v: vid, t: am });
a.m = mark;

@@ -146,3 +119,3 @@ a.ti = ti;

// temp hack
this.deps.length = this.pdi;
// this.deps.length = this.pdi;
this.deps.forEach(function (t) { return removeAtom(t.a, _this); });

@@ -149,0 +122,0 @@ this.deps.length = 0;

@@ -37,25 +37,16 @@ "use strict";

DerivedAtom.prototype.actualize = function () {
var _this = this;
if (this.state === 1 || this.state === 2) {
this.recalc = false;
var deps = this.deps, i = deps.length, t = void 0, a = void 0;
while (i--) {
t = deps[i];
a = t.a;
var ok = this.deps.every(function (t) {
var a = t.a;
a.actualize();
if (a.vid !== t.v) {
this.state = 3;
break;
}
}
// const ok = eachar(this.deps, (t) => {
// const a = t.a;
// a.actualize();
// return a.vid === t.v;
// });
// if (!ok) this.state = 3;
return a.vid === t.v;
});
if (!ok)
this.state = 3;
}
if (this.state === 3) {
var mark = (this.mark = new types_1.Id());
var mark_1 = (this.mark = new types_1.Id());
var prevDeps = this.deps;
this.deps = new Array(prevDeps.length || 10);
this.deps = [];
this.pdi = 0;

@@ -79,35 +70,17 @@ if (!this.isObserved && runtime_1.runtime.currentAtom) {

// temp hack
if (this.deps.length)
this.deps.length = this.pdi;
var deps = prevDeps, i = deps.length, t = void 0, a = void 0;
while (i--) {
a = deps[i].a;
if (a.m !== mark)
(0, shared_1.removeAtom)(a, this);
// if (this.deps.length) this.deps.length = this.pdi;
prevDeps.forEach(function (t) {
var a = t.a;
if (a.m !== mark_1)
(0, shared_1.removeAtom)(a, _this);
a.readFlag = false;
}
// eacha(prevDeps, (t) => {
// const a = t.a;
// if (a.m !== mark) removeAtom(a, this);
// a.readFlag = 0;
// });
deps = this.deps;
i = deps.length;
while (i--) {
t = deps[i];
a = t.a;
});
this.deps.forEach(function (t) {
var a = t.a;
a.m = t.t;
if (a.readFlag) {
a.readFlag = false;
a.subs.add(this);
a.subs.add(_this);
}
}
// eacha(this.deps, (t) => {
// const a = t.a;
// a.m = t.t;
// if (a.readFlag) {
// a.readFlag = 0;
// a.subs.add(this);
// }
// });
});
if (!this.options.equals(nextValue, this.value)) {

@@ -133,5 +106,5 @@ this.value = nextValue;

}
var ti = this.pdi++;
deps[ti] = { a: a, v: vid, t: am }; // literal is faster than class
// deps.push({ a, v: vid, t: am });
var ti = deps.length; // this.pdi++;
// deps[ti] = { a, v: vid, t: am }; // literal is faster than class
deps.push({ a: a, v: vid, t: am });
a.m = mark;

@@ -149,3 +122,3 @@ a.ti = ti;

// temp hack
this.deps.length = this.pdi;
// this.deps.length = this.pdi;
this.deps.forEach(function (t) { return (0, shared_1.removeAtom)(t.a, _this); });

@@ -152,0 +125,0 @@ this.deps.length = 0;

{
"name": "@dhmk/atom",
"version": "2.0.1-test.6",
"version": "2.0.1-test.7",
"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