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

@live-change/dao

Package Overview
Dependencies
Maintainers
1
Versions
253
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/dao - npm Package Compare versions

Comparing version 0.3.6 to 0.3.7

45

lib/DaoPrerenderCache.js

@@ -9,2 +9,3 @@ const debug = require('debug')('reactive-dao:cache')

this.cache = new Map()
this.extendedCache = new Map()
this.mode = mode

@@ -20,3 +21,3 @@ this.observables = new Map()

for(const { what, data } of value) {
this.cache.set(JSON.stringify(what), data)
this.extendedCache.set(JSON.stringify(what), data)
}

@@ -48,3 +49,8 @@ }

this.observables.set(cacheKey, observable)
if (this.cache.has(cacheKey)) observable.restore(this.cache.get(cacheKey))
if(this.cache.has(cacheKey)) observable.restore(this.cache.get(cacheKey))
if(this.extendedCache.has(cacheKey)) {
observable.restore(this.extendedCache.get(cacheKey))
return observable
// do not save extended values
}
if(observable.isInitialized && observable.isInitialized()) {

@@ -57,3 +63,4 @@ if(this.mode == 'save') {

if(this.mode == 'load') {
//if (this.cache.has(cacheKey)) observable.restore(this.cache.get(cacheKey))
// if (this.cache.has(cacheKey)) observable.restore(this.cache.get(cacheKey))
// it was loaded earlier
}

@@ -66,3 +73,3 @@ return observable

debug("GET", cacheKey)
if (this.cache.has(cacheKey)) {
if(this.cache.has(cacheKey)) {
const value = this.cache.get(cacheKey)

@@ -72,2 +79,7 @@ debug("GET FROM CACHE", cacheKey, " => ", value)

}
if(this.extendedCache.has(cacheKey)) {
const value = this.extendedCache.get(cacheKey)
debug("GET FROM EXTENDED CACHE", cacheKey, " => ", value)
return Promise.resolve(value)
}
if(this.mode == 'load') {

@@ -81,9 +93,26 @@ }

if(observable) {
if(typeof observable == 'function') return observable('set', result)
if(observable.notify) {
return observable.notify('set', result)
if(typeof observable == 'function') {
observable('set', result)
} else if(observable.notify) {
observable.notify('set', result)
} else {
observable.set(result)
}
observable.set(result)
}
this.cache.set(cacheKey, result)
if(what.paths) {
for(const { what, data } of result) {
let observable = this.observables.get(cacheKey)
if(observable) {
if(typeof observable == 'function') {
observable('set', data)
} else if(observable.notify) {
observable.notify('set', data)
} else {
observable.set(data)
}
}
this.extendedCache.set(JSON.stringify(what), data)
}
}
})

@@ -90,0 +119,0 @@ }

2

package.json

@@ -39,3 +39,3 @@ {

},
"version": "0.3.6"
"version": "0.3.7"
}
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