MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / makeCallbackWithResource

Function makeCallbackWithResource

test/async_context.js:66–86  ·  view source on GitHub ↗
(binding)

Source from the content-addressed store, hash-verified

64}
65
66async function makeCallbackWithResource (binding) {
67 const hooks = installAsyncHooksForTest('async_context_test');
68 const triggerAsyncId = asyncHooks.executionAsyncId();
69 await new Promise((resolve, reject) => {
70 binding.asynccontext.makeCallback(common.mustCall(), { foo: 'foo' });
71 hooks.then(actual => {
72 assert.deepStrictEqual(actual, [
73 {
74 eventName: 'init',
75 type: 'async_context_test',
76 triggerAsyncId,
77 resource: { foo: 'foo' }
78 },
79 { eventName: 'before' },
80 { eventName: 'after' },
81 { eventName: 'destroy' }
82 ]);
83 }).catch(common.mustNotCall());
84 resolve();
85 });
86}
87
88async function makeCallbackWithoutResource (binding) {
89 const hooks = installAsyncHooksForTest('async_context_no_res_test');

Callers 1

testFunction · 0.85

Calls 1

installAsyncHooksForTestFunction · 0.70

Tested by 1

testFunction · 0.68