Skip to content

Commit

Permalink
remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
lroal committed Aug 11, 2020
1 parent c946d07 commit 7534858
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/async.js
@@ -1,12 +1,12 @@
let cls = require('../index');

let context = cls.create('myContext');
let key = Symbol();
let context = cls.create(key);
context.run(() => {
context.name = 'George';
setTimeout(onTimeout, 300);
});

function onTimeout() {
let context = cls.get('myContext');
let context = cls.get(key);
console.log(context.name); //George
}
5 changes: 1 addition & 4 deletions index-core.js
Expand Up @@ -134,8 +134,7 @@ function init(asyncId, _type, triggerId) {
}

function log(str) {
if (cls.debug)
fs.writeSync(1, `${str}\n`);
fs.writeSync(1, `${str}\n`);
}

function destroy(asyncId) {
Expand All @@ -145,8 +144,6 @@ function destroy(asyncId) {
log(`destroy ${ asyncId} : ${ Object.keys(stack).length}`);
log(`keys ${ Object.keys(stack)}`);
}

delete stack[asyncId];
}

module.exports = cls;

0 comments on commit 7534858

Please sign in to comment.