New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@exodus/atoms

Package Overview
Dependencies
Maintainers
89
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/atoms - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

8

package.json
{
"name": "@exodus/atoms",
"version": "5.2.1",
"version": "5.2.2",
"main": "src/index.js",

@@ -19,3 +19,3 @@ "description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe",

},
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/modules/atom",
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/libraries/atoms",
"license": "UNLICENSED",

@@ -36,6 +36,6 @@ "bugs": {

"delay": "^5.0.0",
"eslint": "^8.33.0",
"eslint": "^8.44.0",
"jest": "^29.1.2"
},
"gitHead": "3cc58449431fce7a8fa18be6d7f389727d09665b"
"gitHead": "4b2c9803b5d53c65b77475187777ae5633e5d619"
}

@@ -6,20 +6,42 @@ import createCountdownLock from '../countdown-lock'

const combine = (atoms) => {
const { notify, observe } = createSimpleObserver()
const { notify, observe: observeSimpleObserver } = createSimpleObserver()
const countdownLock = createCountdownLock(Object.keys(atoms))
let values = {}
let subscriptions = []
let subscribers = 0
for (const name in atoms) {
atoms[name].observe(async (value) => {
values = {
...values,
[name]: value,
}
if (countdownLock.unlock(name)) await notify(values)
})
const maybeUnsubscribeSourceObservables = () => {
subscribers -= 1
if (subscribers > 0) return
subscriptions.forEach((unsubscribe) => unsubscribe())
subscriptions = []
}
const observe = (callback) => {
subscribers += 1
if (subscribers === 1) {
subscriptions = Object.entries(atoms).map(([name, atom]) =>
atom.observe(async (value) => {
values = {
...values,
[name]: value,
}
if (countdownLock.unlock(name)) await notify(values)
})
)
}
const unsubscribe = observeSimpleObserver(callback)
return () => {
unsubscribe()
maybeUnsubscribeSourceObservables()
}
}
const get = async () => {
await countdownLock.promise
return values
return Object.fromEntries(
await Promise.all(Object.entries(atoms).map(async ([name, atom]) => [name, await atom.get()]))
)
}

@@ -26,0 +48,0 @@

import createSimpleObserver from '../simple-observer'
import enforceObservableRules from '../enforce-rules'
import pDefer from 'p-defer'

@@ -10,8 +11,12 @@ const createStorageAtomFactory =

let cached
let writePromiseDefer
const set = async (value) => {
if (value === undefined) {
writePromiseDefer = pDefer()
await storage.delete(key)
} else {
writePromiseDefer = pDefer()
await storage.set(key, value)
}
writePromiseDefer.resolve()

@@ -29,2 +34,9 @@ if (isSoleWriter) {

if (writePromiseDefer) {
await writePromiseDefer.promise
}
if (cached) {
return cached
}
const value = await storage.get(key)

@@ -31,0 +43,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