Comparing version 2.1.1 to 2.1.2
# CHANGELOG | ||
| Release | Notes | | ||
|-----------|-----------------------------------------------------------------------------------------| | ||
| 2.1.0-1 | maintenance release, nodejs 14 support | | ||
| --------- | --------------------------------------------------------------------------------------- | | ||
| 2.1.0-2 | maintenance release, nodejs 14 support | | ||
| 2.0.18-19 | deprecated in favour of AsyncLocalStorage | | ||
@@ -7,0 +7,0 @@ | 2.0.12-17 | maintenance release, nodejs 14 support | |
{ | ||
"name": "asyncctx", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "an asynchronous execution context for TypeScript/JavaScript", | ||
"deprecated": "deprecated in favour of AsyncLocalStorage", | ||
"keywords": [ | ||
@@ -27,6 +28,7 @@ "typescript", | ||
"dependencies": { | ||
"tslib": "^2.6.2" | ||
"tslib": "^2.8.0" | ||
}, | ||
"main": "./src/index.js", | ||
"type": "commonjs" | ||
} | ||
"type": "commonjs", | ||
"types": "./src/index.d.ts" | ||
} |
@@ -26,11 +26,11 @@ [![npm version](https://badge.fury.io/js/asyncctx.svg)](https://badge.fury.io/js/asyncctx) | ||
```Typescript | ||
class ContinuationLocalStorage<T> extends AsyncLocalStorage<T> { | ||
public getContext(): T | undefined { | ||
return this.getStore(); | ||
} | ||
public setContext(value: T): T { | ||
this.enterWith(value); | ||
return value; | ||
} | ||
class ContinuationLocalStorage<T> extends AsyncLocalStorage<T> { | ||
public getContext(): T | undefined { | ||
return this.getStore(); | ||
} | ||
public setContext(value: T): T { | ||
this.enterWith(value); | ||
return value; | ||
} | ||
} | ||
``` | ||
@@ -50,10 +50,10 @@ | ||
let cls = new ContinuationLocalStorage<MyLocalStorage>(); | ||
cls.setRootContext({ value: 1}); | ||
cls.setRootContext({ value: 1 }); | ||
process.nextTick(() => { | ||
let curr1 = cls.getContext(); // value is 1 | ||
cls.setContext({ value: 2}); // value should be 2 in the current execution context and below | ||
cls.setContext({ value: 2 }); // value should be 2 in the current execution context and below | ||
process.nextTick(() => { | ||
let curr2 = cls.getContext(); // value is 2 | ||
cls.setContext({ value: 3}); // value should be 3 in the current execution context and below | ||
cls.setContext({ value: 3 }); // value should be 3 in the current execution context and below | ||
process.nextTick(() => { | ||
@@ -77,2 +77,1 @@ let curr3 = cls.getContext(); // value is 3 | ||
[LICENSE](./LICENSE) | ||
@@ -1,6 +0,3 @@ | ||
/// <reference types="node" /> | ||
import { AsyncLocalStorage } from 'async_hooks'; | ||
/** | ||
* | ||
* | ||
* @export | ||
@@ -7,0 +4,0 @@ * @class AsynchronousLocalStorage |
@@ -6,4 +6,2 @@ "use strict"; | ||
/** | ||
* | ||
* | ||
* @export | ||
@@ -10,0 +8,0 @@ * @class AsynchronousLocalStorage |
@@ -33,3 +33,2 @@ interface HookInfo<T> { | ||
* Creates an instance of ContinuationLocalStorage. | ||
* | ||
*/ | ||
@@ -90,3 +89,2 @@ constructor(); | ||
* enable | ||
* | ||
*/ | ||
@@ -96,3 +94,2 @@ enable(): void; | ||
* disable | ||
* | ||
*/ | ||
@@ -99,0 +96,0 @@ disable(): void; |
@@ -33,3 +33,2 @@ "use strict"; | ||
* Creates an instance of ContinuationLocalStorage. | ||
* | ||
*/ | ||
@@ -232,3 +231,2 @@ constructor() { | ||
* enable | ||
* | ||
*/ | ||
@@ -241,3 +239,2 @@ enable() { | ||
* disable | ||
* | ||
*/ | ||
@@ -244,0 +241,0 @@ disable() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
26196
426
75
Updatedtslib@^2.8.0