@fangxq/async-context
Advanced tools
Comparing version 1.0.0 to 1.0.1
14
index.js
@@ -21,3 +21,3 @@ const AsyncLocalStorage = require('async_hooks').AsyncLocalStorage | ||
if (publicConstructor[path]) { | ||
if (!publicContext[path]) publicContext[path] = new publicConstructor[path]() | ||
if (!publicContext[path]) publicContext[path] = createModule(publicConstructor[path]) | ||
@@ -29,3 +29,3 @@ return publicContext[path] | ||
if (!privateContext[token]) privateContext[token] = {} | ||
if (!privateContext[token][path]) privateContext[token][path] = new privateConstructor[path]() | ||
if (!privateContext[token][path]) privateContext[token][path] = createModule(privateConstructor[path]) | ||
@@ -36,2 +36,12 @@ return privateContext[token][path] | ||
function createModule(ctr) { | ||
const obj = new ctr() | ||
Object.keys(ctr.prototype).forEach(k => { | ||
obj[k] = ctr.prototype[k].bind(obj) | ||
}) | ||
return obj | ||
} | ||
module.exports.asyncContext = { | ||
@@ -38,0 +48,0 @@ definePrivate(path, ctr) { |
{ | ||
"name": "@fangxq/async-context", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
2709
79