Socket
Socket
Sign inDemoInstall

@fangxq/async-context

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fangxq/async-context - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

3

index.d.ts

@@ -8,5 +8,4 @@ export const asyncContext: {

clearAll(): void
useAsync<T>(token: string, fn: () => Promise<T>): Promise<T>
useSync<T>(token: string, fn: () => T): T
use<T>(token: string, fn: () => Promise<T>): Promise<T>
getCurrentContext(): string
}

@@ -37,3 +37,3 @@ const cloneDeep = require('lodash').cloneDeep

function getPrivateValues() {
const token = store.getStore() ?? syncToken
const token = store.getStore()
if (!self.privateValues[token]) {

@@ -59,7 +59,5 @@ self.privateValues[token] = cloneDeep(self.defaultPrivateValues)

let syncToken = ''
module.exports.asyncContext = {
definePrivate(path, proName, defaultValue) {
if (!dataContext[path]) dataContext[path] = new contextObject()
if(!dataContext[path]) dataContext[path] = new contextObject()

@@ -69,3 +67,3 @@ dataContext[path].definePrivateValue(proName, defaultValue)

definePublic(path, proName, defaultValue) {
if (!dataContext[path]) dataContext[path] = new contextObject()
if(!dataContext[path]) dataContext[path] = new contextObject()

@@ -90,3 +88,3 @@ dataContext[path].definePublicValue(proName, defaultValue)

},
useAsync(token, fn) {
use(token, fn) {
return new Promise((resolve, reject) => {

@@ -102,13 +100,5 @@ store.run(token, async () => {

},
useSync(token, fn) {
try {
syncToken = token
return fn()
} finally {
syncToken = ''
}
},
getCurrentContext() {
return store.getStore() ?? syncToken
return store.getStore()
}
}
{
"name": "@fangxq/async-context",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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