Skip to content

Commit 334a450

Browse files
committed
init.
1 parent b5e87fa commit 334a450

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/hooks/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ describe('Context / Hooks', () => {
152152
it('Triggers parent cleanup when all child process died', (done) => {
153153
children.forEach(destroy);
154154

155-
process.nextTick(() => {
155+
setTimeout(() => {
156156
expect(executionMap.size).toEqual(0);
157157

158158
done();
159-
});
159+
}, 200)
160160
});
161161
});
162162
});

src/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ const createExecutionContext = () => {
105105

106106
fn();
107107
});
108+
},
109+
110+
/**
111+
* Monitors current execution map usage
112+
* @return {ExecutionMapUsage}
113+
*/
114+
monitor: () => {
115+
console.log('Minotir runnig');
116+
117+
return {
118+
size: executionContextMap.size,
119+
entries: [...executionContextMap.values()]
120+
}
108121
}
109122
};
110123

src/types.d.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ interface HookCallbacks {
3131
destroy?(asyncId: number): void;
3232
}
3333

34+
interface ExecutionMapUsageEntry {
35+
asyncId: number;
36+
type: string;
37+
}
38+
39+
interface ExecutionMapUsage {
40+
size: number;
41+
entries: ExecutionMapUsageEntry[];
42+
}
43+
3444
interface ExecutionContextAPI {
3545

3646
/**
@@ -48,12 +58,17 @@ interface ExecutionContextAPI {
4858
/**
4959
* Gets the current async process execution context.
5060
*/
51-
get(): object
61+
get(): object;
5262

5363
/**
5464
* Runs a given function within an async resource context
5565
* @param fn
5666
* @param initialContext
5767
*/
58-
run(fn: Function, initialContext: object): void
68+
run(fn: Function, initialContext: object): void;
69+
70+
/**
71+
* Monitors the current execution map usage
72+
*/
73+
monitor(): ExecutionMapUsage;
5974
}

0 commit comments

Comments
 (0)