2019-03-01 21:31:36 +01:00
|
|
|
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const { AsyncLocalStorage } = require('async_hooks');
|
|
|
|
|
|
|
|
const asyncLocalStorage = new AsyncLocalStorage();
|
|
|
|
|
|
|
|
async function test() {
|
|
|
|
asyncLocalStorage.getStore().set('foo', 'bar');
|
|
|
|
await Promise.resolve();
|
|
|
|
assert.strictEqual(asyncLocalStorage.getStore().get('foo'), 'bar');
|
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
2020-03-14 09:06:06 +03:00
|
|
|
await asyncLocalStorage.run(new Map(), test);
|
2019-03-01 21:31:36 +01:00
|
|
|
assert.strictEqual(asyncLocalStorage.getStore(), undefined);
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|