0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/async-hooks/test-disable-in-init.js
garygsc b27e2408af test: use arrow functions in async-hooks tests
Convert all anonymous callback functions in `test/async-hooks/*.js`
to use arrow functions.

`writing-tests.md` states to use arrow functions when appropriate.

PR-URL: https://github.com/nodejs/node/pull/30137
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-12-02 20:03:17 +05:30

24 lines
482 B
JavaScript

'use strict';
const common = require('../common');
const async_hooks = require('async_hooks');
const fs = require('fs');
let nestedCall = false;
async_hooks.createHook({
init: common.mustCall(() => {
nestedHook.disable();
if (!nestedCall) {
nestedCall = true;
fs.access(__filename, common.mustCall());
}
}, 2)
}).enable();
const nestedHook = async_hooks.createHook({
init: common.mustCall(2)
}).enable();
fs.access(__filename, common.mustCall());