Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
'use strict';
var asyncWrap = process.binding('async_wrap');
var fs = require('fs');
var asyncHooksObject = {};
var kCallInitHook = 0;
asyncHooksObject[kCallInitHook] = 1;
//asyncHooksObject = new Uint8Array([1]);
//asyncHooksObject = new Buffer([1]);
asyncWrap.setupHooks(asyncHooksObject, init, before, after);
function init() {
writeSync(JSON.stringify(arguments));
writeSync('Init called');
}
function before() {
writeSync(JSON.stringify(arguments));
writeSync('Before called');
}
function after() {
writeSync(JSON.stringify(arguments));
writeSync('After called');
}
setTimeout(function () {
writeSync('Callback called');
}, 15);
function writeSync(text) {
fs.writeSync(1, text + '\n');
fs.fsyncSync(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.