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

dexie-relay

Package Overview
Dependencies
Maintainers
0
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dexie-relay - npm Package Compare versions

Comparing version 1.0.3 to 1.0.5

56

index.js

@@ -57,10 +57,14 @@ import {Client} from 'relay-to-relay'

const updates = new Map()
const adds = new Set()
const edits = new Map()
const subs = new Set()
const routine = setInterval(() => {
for(const [prop, update] of updates.entries()){
if((Date.now() - update) > 900000){
updates.delete(prop)
adds.clear()
for(const [prop, update] of edits.entries()){
if((Date.now() - update) > 300000){
edits.delete(prop)
}
}
subs.clear()
}, 180000)

@@ -138,37 +142,41 @@

}
const datas = JSON.parse(data)
if(datas.user === user){
return
}
if(db[datas.name]){
if(datas.status){
if(datas.user === user){
return
}
if(datas.status === 'add'){
if(datas.user !== user){
await db[datas.name].add(datas.data)
if(adds.has(datas.iden)){
return
}
client.onMesh(data, nick)
await db[datas.name].add(datas.data)
adds.add(datas.iden)
} else if(datas.status === 'edit'){
if(datas.user !== user){
if(updates.has(datas.iden)){
const test = updates.get(datas.iden)
if(datas.edit > test){
updates.set(datas.iden, datas.edit)
await db[datas.name].update(datas.iden, datas.data)
}
if(edits.has(datas.iden)){
const test = edits.get(datas.iden)
if(datas.edit > test){
await db[datas.name].update(datas.iden, datas.data)
edits.set(datas.iden, datas.edit)
} else {
updates.set(datas.iden, datas.edit)
await db[datas.name].update(datas.iden, datas.data)
return
}
} else {
await db[datas.name].update(datas.iden, datas.data)
edits.set(datas.iden, datas.edit)
}
client.onMesh(data, nick)
} else if(datas.status === 'sub'){
if(!keep){
if(datas.user !== user){
await db[datas.name].delete(datas.iden)
if(subs.has(datas.iden)){
return
}
await db[datas.name].delete(datas.iden)
subs.add(datas.iden)
}
client.onMesh(data, nick)
} else {
return
}
client.onMesh(data, nick)
} else {

@@ -244,3 +252,3 @@ if(datas.session){

clearInterval(routine)
updates.clear()
edits.clear()
client.off('connect', connect)

@@ -247,0 +255,0 @@ client.off('error', err)

{
"name": "dexie-relay",
"version": "1.0.3",
"version": "1.0.5",
"main": "index.js",

@@ -5,0 +5,0 @@ "scripts": {

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