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

quarx

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quarx - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

24

dist/index.js

@@ -67,3 +67,7 @@ var __defProp = Object.defineProperty;

}
function autorun(computation) {
function autorun(computation, options = {}) {
const {name = "autorun"} = options;
const onError = options.onError || function(e) {
console.log(`[Quarx]: uncaught exception in ${name}:`, e);
};
let dependencies = new Set();

@@ -74,3 +78,3 @@ let seqNo = 0, isRunning = false;

if (stack.length && seqNo === sequenceNumber) {
throw new Error("Circular dependency detected");
throw new Error(`[Quarx]: Circular dependency detected in ${name}`);
}

@@ -94,3 +98,3 @@ seqNo = 0;

if (isRunning) {
throw new Error("Self-dependency detected");
throw new Error(`[Quarx]: Self-dependency detected in ${name}`);
}

@@ -101,3 +105,7 @@ isRunning = true;

stack.push({link, invalidate, actualize});
computation();
try {
computation();
} catch (e) {
onError(e);
}
stack.pop();

@@ -146,3 +154,3 @@ for (let dep of previousDeps) {

name = "computed",
equal = (a, b) => a === b
equals = (a, b) => a === b
} = options;

@@ -154,3 +162,3 @@ let result, error;

const value = evaluate();
if (!error && equal(result, value))
if (!error && equals(result, value))
return;

@@ -181,3 +189,3 @@ result = value;

name = "box",
equal = (a, b) => a === b
equals = (a, b) => a === b
} = options;

@@ -187,3 +195,3 @@ const atom = createAtom(name);

set(newValue) {
if (!equal(newValue, value)) {
if (!equals(newValue, value)) {
value = newValue;

@@ -190,0 +198,0 @@ atom.reportChanged();

@@ -22,3 +22,3 @@ declare module 'quarx' {

name?: string;
equal?: (a: T, b: T) => boolean;
equals?: (a: T, b: T) => boolean;
}

@@ -25,0 +25,0 @@

@@ -7,3 +7,3 @@ {

"name": "quarx",
"version": "1.0.1",
"version": "2.0.0",
"description": "Simple dependency graph engine, MobX inspired",

@@ -10,0 +10,0 @@ "main": "dist/index.js",

@@ -88,3 +88,3 @@ # 🜉 Quarx

name?: string;
equal?: (a: T, b: T) => boolean;
equals?: (a: T, b: T) => boolean;
}

@@ -100,5 +100,5 @@

*Box* observables are the upstream leaves of the computations DAG. `aBox.get()` reports the box observed to the calling computation, and `aBox.set(value)` will report it changed if the `value` is different from the current one in the sense of the `equal` option (`===` by default). A *Box* in Quarx is never trying to make its content deeply observable like MobX. It represents a *single* observable value.
*Box* observables are the upstream leaves of the computations DAG. `aBox.get()` reports the box observed to the calling computation, and `aBox.set(value)` will report it changed if the `value` is different from the current one in the sense of the `equals` option (`===` by default). A *Box* in Quarx is never trying to make its content deeply observable like MobX. It represents a *single* observable value.
*Computed* observables are the intermediate nodes of the DAG representing the *reactive derivations*. `aComputed.get()` returns the result of the computation. If the computation threw an error, the `computed` will store it and re-throw on `get()`. Only if the computation result is different from the previously computed one in the sense of the `equal` option (`===` by default), the change will be reported downstream.
*Computed* observables are the intermediate nodes of the DAG representing the *reactive derivations*. `aComputed.get()` returns the result of the computation. If the computation threw an error, the `computed` will store it and re-throw on `get()`. Only if the computation result is different from the previously computed one in the sense of the `equals` option (`===` by default), the change will be reported downstream.

@@ -105,0 +105,0 @@ Computed observables are lazy: if they don't have any observers they will unsubscribe from all their upstream dependencies.

@@ -6,3 +6,3 @@ import { createAtom } from './core';

name = 'box',
equal = (a, b) => a === b
equals = (a, b) => a === b
} = options;

@@ -14,3 +14,3 @@

set(newValue) {
if (!equal(newValue, value)) {
if (!equals(newValue, value)) {
value = newValue;

@@ -17,0 +17,0 @@ atom.reportChanged();

@@ -6,3 +6,3 @@ import { createAtom, autorun } from './core';

name = 'computed',
equal = (a, b) => a === b
equals = (a, b) => a === b
} = options;

@@ -17,3 +17,3 @@

const value = evaluate();
if (!error && equal(result, value)) return;
if (!error && equals(result, value)) return;
result = value;

@@ -20,0 +20,0 @@ error = null;

@@ -55,3 +55,8 @@ const stack = [];

export function autorun(computation) {
export function autorun(computation, options = {}) {
const { name = 'autorun' } = options;
const onError = options.onError || function(e) {
console.log(`[Quarx]: uncaught exception in ${name}:`, e);
}
let dependencies = new Set();

@@ -64,3 +69,3 @@ let seqNo = 0, isRunning = false;

if (stack.length && seqNo === sequenceNumber) {
throw new Error('Circular dependency detected');
throw new Error(`[Quarx]: Circular dependency detected in ${name}`);
}

@@ -84,3 +89,3 @@ seqNo = 0;

if (isRunning) {
throw new Error('Self-dependency detected');
throw new Error(`[Quarx]: Self-dependency detected in ${name}`);
}

@@ -93,3 +98,10 @@ isRunning = true;

stack.push({ link, invalidate, actualize });
computation();
try {
computation();
}
catch (e) {
onError(e);
}
stack.pop();

@@ -96,0 +108,0 @@

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