Comparing version 4.0.0 to 4.0.1
{ | ||
"name": "quarx", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Simple dependency graph engine, MobX inspired", | ||
@@ -17,3 +17,3 @@ "type": "module", | ||
"devDependencies": { | ||
"ava": "^4.0.1" | ||
"ava": "^4.3.3" | ||
}, | ||
@@ -20,0 +20,0 @@ "ava": { |
@@ -15,2 +15,3 @@ const TAG = '@dmaevsky/quarx'; | ||
batchDepth: 0, | ||
processingQueue: 0, | ||
debug: () => {}, | ||
@@ -79,3 +80,3 @@ error: console.error | ||
if (!Quarx.batchDepth) hydrate(); | ||
hydrate(); | ||
} | ||
@@ -97,2 +98,5 @@ } | ||
function invalidate() { | ||
if (Quarx.processingQueue + (seqNo === Quarx.sequenceNumber) >= 2) { | ||
return Quarx.debug(`[Quarx]: prevent invalidating ${name} ${Quarx.processingQueue === 1 ? ': cycle detected' : 'during cleanup'}`); | ||
} | ||
seqNo = 0; | ||
@@ -105,3 +109,5 @@ Quarx.invalidated.add(run); | ||
const trace = [...Quarx.stack.map(({ name }) => name), name]; | ||
throw new Error(`[Quarx]: Circular dependency detected: ${trace.join(' -> ')}`); | ||
const message = `[Quarx]: Circular dependency detected: ${trace.join(' -> ')}`; | ||
Quarx.debug(message); | ||
throw new Error(message); | ||
} | ||
@@ -113,8 +119,12 @@ if (seqNo === Quarx.sequenceNumber) return; | ||
for (let dep of dependencies) { | ||
dep.actualize(); | ||
if (!seqNo) break; | ||
try { | ||
for (let dep of dependencies) { | ||
dep.actualize(); | ||
if (!seqNo) break; | ||
} | ||
} | ||
finally { | ||
Quarx.stack.pop(); | ||
} | ||
Quarx.stack.pop(); | ||
if (!seqNo) return run(); | ||
@@ -152,3 +162,3 @@ | ||
dependencies.clear(); | ||
if (!Quarx.batchDepth) collectUnobserved(); | ||
collectUnobserved(); | ||
} | ||
@@ -161,5 +171,7 @@ | ||
function collectUnobserved() { | ||
++Quarx.batchDepth; | ||
if (Quarx.batchDepth + Quarx.processingQueue) return; | ||
Quarx.processingQueue += 2; | ||
for (let dispose of Quarx.pendingDispose) dispose(); | ||
--Quarx.batchDepth; | ||
Quarx.processingQueue -= 2; | ||
@@ -170,3 +182,3 @@ Quarx.pendingDispose.clear(); | ||
function hydrate() { | ||
if (!Quarx.invalidated.size) return; | ||
if (!Quarx.invalidated.size || Quarx.batchDepth + Quarx.processingQueue) return; | ||
@@ -176,5 +188,5 @@ ++Quarx.sequenceNumber; | ||
++Quarx.batchDepth; | ||
++Quarx.processingQueue; | ||
for (let run of Quarx.invalidated) run(); | ||
--Quarx.batchDepth; | ||
--Quarx.processingQueue; | ||
@@ -194,3 +206,3 @@ collectUnobserved(); | ||
} | ||
if (!Quarx.batchDepth) hydrate(); | ||
hydrate(); | ||
} | ||
@@ -197,0 +209,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15834
257