GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/test/node-api/test_callback_scope/test-async-hooks.js at main · styfle/node Expand file tree/ Copy pathtest-async-hooks.jsMore file actions 39 lines (34 loc) · 1.15 KB / Copy pathtest-async-hooks.jsFile metadata and controls39 lines (34 loc) · 1.15 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 'use strict'; const common = require('../../common'); const assert = require('assert'); const async_hooks = require('async_hooks'); // The async_hook that we enable would register the process.emitWarning() // call from loading the N-API addon as asynchronous activity because // it contains a process.nextTick() call. Monkey patch it to be a no-op // before we load the addon in order to avoid this. process.emitWarning = () => {}; const { runInCallbackScope } = require(`./build/${common.buildType}/binding`); const expectedResource = {}; const expectedResourceType = 'test-resource'; let insideHook = false; let expectedId; async_hooks.createHook({ init: common.mustCall((id, type, triggerAsyncId, resource) => { if (type !== expectedResourceType) { return; } assert.strictEqual(resource, expectedResource); expectedId = id; }), before: common.mustCall((id) => { assert.strictEqual(id, expectedId); insideHook = true; }), after: common.mustCall((id) => { assert.strictEqual(id, expectedId); insideHook = false; }) }).enable(); runInCallbackScope(expectedResource, expectedResourceType, () => { assert(insideHook); }); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |