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

3

esm/atoms/computed.d.ts
import { Id, AtomState, Dependency, AtomOptions, Atom } from "../types";
export declare class ComputedAtom<T> {
private fn;
observers: Map<Atom, Id>;
observers: Atom[];
deps: Dependency[];

@@ -12,2 +12,3 @@ prevDeps: Dependency[];

depsForUnobserved: Set<Dependency>;
wm: WeakMap<object, any>;
protected value: unknown;

@@ -14,0 +15,0 @@ protected isError: boolean;

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

this.fn = fn;
this.observers = new Map();
this.observers = Array();
this.deps = Array();

@@ -27,2 +27,3 @@ this.prevDeps = Array();

this.depsForUnobserved = new Set();
this.wm = new WeakMap();
this.isError = false;

@@ -38,3 +39,3 @@ this.state = AtomState.Stale;

if (oldState === AtomState.Actual)
this.observers.forEach(function (_, a) {
this.observers.forEach(function (a) {
return a.invalidate(AtomState.PossiblyStale, false);

@@ -73,3 +74,3 @@ });

var dep = this.deps[i];
dep.runId = this.runId;
// dep.runId = this.runId;
this.depsVersions[i] = dep.versionId;

@@ -79,4 +80,7 @@ }

var a = this.prevDeps[i];
if (a.runId !== this.runId)
// if (a.runId !== this.runId) removeAtom(a, this);
if (this.wm.get(a).runId !== this.runId) {
this.wm.delete(a);
removeAtom(a, this);
}
}

@@ -89,3 +93,3 @@ this.prevDeps = [];

this.versionId = new Id();
this.observers.forEach(function (_, a) { return a.invalidate(AtomState.Stale, false); });
this.observers.forEach(function (a) { return a.invalidate(AtomState.Stale, false); });
}

@@ -92,0 +96,0 @@ };

import { AtomOptions, Atom, Id } from "../types";
export declare class ValueAtom<T> {
private value;
observers: Map<Atom, Id>;
observers: Atom[];
runId: Id;

@@ -6,0 +6,0 @@ versionId: Id;

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

this.value = value;
this.observers = new Map();
this.observers = Array();
this.runId = new Id();

@@ -26,3 +26,3 @@ this.versionId = new Id();

ValueAtom.prototype.invalidate = function () {
this.observers.forEach(function (_, a) { return a.invalidate(AtomState.Stale, true); });
this.observers.forEach(function (a) { return a.invalidate(AtomState.Stale, true); });
runtime.runEffects();

@@ -29,0 +29,0 @@ };

@@ -46,3 +46,3 @@ import { ValueAtom } from "../atoms/value";

if (!a) {
a = v[AS] ? v[AS] : new ValueAtom(creator(v, p));
a = (v === null || v === void 0 ? void 0 : v[AS]) ? v[AS] : new ValueAtom(creator(v, p));
atoms.set(p, a);

@@ -56,3 +56,3 @@ }

var v_1 = t[p];
a = v_1[AS] ? v_1[AS] : new ValueAtom(undefined);
a = (v_1 === null || v_1 === void 0 ? void 0 : v_1[AS]) ? v_1[AS] : new ValueAtom(undefined);
atoms.set(p, a);

@@ -59,0 +59,0 @@ }

@@ -12,2 +12,3 @@ import { Dependency, Id } from "./types";

depsForUnobserved: Set<Dependency>;
wm: WeakMap<any, any>;
}

@@ -14,0 +15,0 @@ export declare const runtime: {

@@ -1,4 +0,4 @@

import { Dependency, Id } from "./types";
import { Dependency } from "./types";
type WithObservers = {
observers: Map<unknown, Id>;
observers: Array<any>;
};

@@ -5,0 +5,0 @@ type Disposable = {

import { runtime } from "./runtime";
export var removeAtom = function (a, self) {
a.observers.delete(self);
if (!a.observers.size)
// a.observers.delete(self);
// a.observers.splice(a.observers.indexOf(self));
a.observers = a.observers.filter(function (x) { return x !== self; });
if (!a.observers.length)
a.dispose();

@@ -22,7 +24,18 @@ };

self.depsForUnobserved.add(a);
self.wm.set(a, { runId: {} });
return;
}
var cid = a.observers.get(self);
if (cid !== self.runId) {
a.observers.set(self, self.runId);
// const cid = a.observers.get(self);
// if (cid !== self.runId) {
// a.observers.set(self, self.runId);
// self.deps.push(a);
// }
var x = self.wm.get(a);
if (!x) {
x = { runId: {} };
self.wm.set(a, x);
a.observers.push(self);
}
if (x.runId !== self.runId) {
x.runId = a.runId = self.runId;
self.deps.push(a);

@@ -29,0 +42,0 @@ }

@@ -7,3 +7,3 @@ export declare class Id {

dispose(): void;
observers: Map<unknown, Id>;
observers: Array<any>;
versionId: Id;

@@ -10,0 +10,0 @@ runId: Id;

import { Id, AtomState, Dependency, AtomOptions, Atom } from "../types";
export declare class ComputedAtom<T> {
private fn;
observers: Map<Atom, Id>;
observers: Atom[];
deps: Dependency[];

@@ -12,2 +12,3 @@ prevDeps: Dependency[];

depsForUnobserved: Set<Dependency>;
wm: WeakMap<object, any>;
protected value: unknown;

@@ -14,0 +15,0 @@ protected isError: boolean;

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

this.fn = fn;
this.observers = new Map();
this.observers = Array();
this.deps = Array();

@@ -30,2 +30,3 @@ this.prevDeps = Array();

this.depsForUnobserved = new Set();
this.wm = new WeakMap();
this.isError = false;

@@ -41,3 +42,3 @@ this.state = types_1.AtomState.Stale;

if (oldState === types_1.AtomState.Actual)
this.observers.forEach(function (_, a) {
this.observers.forEach(function (a) {
return a.invalidate(types_1.AtomState.PossiblyStale, false);

@@ -76,3 +77,3 @@ });

var dep = this.deps[i];
dep.runId = this.runId;
// dep.runId = this.runId;
this.depsVersions[i] = dep.versionId;

@@ -82,4 +83,7 @@ }

var a = this.prevDeps[i];
if (a.runId !== this.runId)
// if (a.runId !== this.runId) removeAtom(a, this);
if (this.wm.get(a).runId !== this.runId) {
this.wm.delete(a);
(0, shared_1.removeAtom)(a, this);
}
}

@@ -92,3 +96,3 @@ this.prevDeps = [];

this.versionId = new types_1.Id();
this.observers.forEach(function (_, a) { return a.invalidate(types_1.AtomState.Stale, false); });
this.observers.forEach(function (a) { return a.invalidate(types_1.AtomState.Stale, false); });
}

@@ -95,0 +99,0 @@ };

import { AtomOptions, Atom, Id } from "../types";
export declare class ValueAtom<T> {
private value;
observers: Map<Atom, Id>;
observers: Atom[];
runId: Id;

@@ -6,0 +6,0 @@ versionId: Id;

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

this.value = value;
this.observers = new Map();
this.observers = Array();
this.runId = new types_1.Id();

@@ -29,3 +29,3 @@ this.versionId = new types_1.Id();

ValueAtom.prototype.invalidate = function () {
this.observers.forEach(function (_, a) { return a.invalidate(types_1.AtomState.Stale, true); });
this.observers.forEach(function (a) { return a.invalidate(types_1.AtomState.Stale, true); });
runtime_1.runtime.runEffects();

@@ -32,0 +32,0 @@ };

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

if (!a) {
a = v[AS] ? v[AS] : new value_1.ValueAtom(creator(v, p));
a = (v === null || v === void 0 ? void 0 : v[AS]) ? v[AS] : new value_1.ValueAtom(creator(v, p));
atoms.set(p, a);

@@ -60,3 +60,3 @@ }

var v_1 = t[p];
a = v_1[AS] ? v_1[AS] : new value_1.ValueAtom(undefined);
a = (v_1 === null || v_1 === void 0 ? void 0 : v_1[AS]) ? v_1[AS] : new value_1.ValueAtom(undefined);
atoms.set(p, a);

@@ -63,0 +63,0 @@ }

@@ -12,2 +12,3 @@ import { Dependency, Id } from "./types";

depsForUnobserved: Set<Dependency>;
wm: WeakMap<any, any>;
}

@@ -14,0 +15,0 @@ export declare const runtime: {

@@ -1,4 +0,4 @@

import { Dependency, Id } from "./types";
import { Dependency } from "./types";
type WithObservers = {
observers: Map<unknown, Id>;
observers: Array<any>;
};

@@ -5,0 +5,0 @@ type Disposable = {

@@ -6,4 +6,6 @@ "use strict";

var removeAtom = function (a, self) {
a.observers.delete(self);
if (!a.observers.size)
// a.observers.delete(self);
// a.observers.splice(a.observers.indexOf(self));
a.observers = a.observers.filter(function (x) { return x !== self; });
if (!a.observers.length)
a.dispose();

@@ -27,7 +29,18 @@ };

self.depsForUnobserved.add(a);
self.wm.set(a, { runId: {} });
return;
}
var cid = a.observers.get(self);
if (cid !== self.runId) {
a.observers.set(self, self.runId);
// const cid = a.observers.get(self);
// if (cid !== self.runId) {
// a.observers.set(self, self.runId);
// self.deps.push(a);
// }
var x = self.wm.get(a);
if (!x) {
x = { runId: {} };
self.wm.set(a, x);
a.observers.push(self);
}
if (x.runId !== self.runId) {
x.runId = a.runId = self.runId;
self.deps.push(a);

@@ -34,0 +47,0 @@ }

@@ -7,3 +7,3 @@ export declare class Id {

dispose(): void;
observers: Map<unknown, Id>;
observers: Array<any>;
versionId: Id;

@@ -10,0 +10,0 @@ runId: Id;

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

@@ -34,3 +34,3 @@ "keywords": [

"version": "git add -A",
"postversion": "git push && git push --tags",
"postversion": "git push origin HEAD && git push origin HEAD --tags",
"clean": "rm -rf lib esm",

@@ -37,0 +37,0 @@ "build": "yarn clean && tsc && tsc -m esnext --outDir esm",

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