'use strict';

var nodeMajorVersion = parseInt(process.versions.node);

if (nodeMajorVersion > 8) {
  var async_hooks = require('async_hooks');
  async_hooks.supported = true;
  module.exports = async_hooks;
} else {
  var AsyncResource = function() {};
  AsyncResource.prototype.runInAsyncScope = function(fn, thisArg) {
    var args = [];
    for (var i = 2; i < arguments.length; ++i) {
      args.push(arguments[i]);
    }
    return fn.apply(thisArg, args);
  };

  var async_hooks_cn = {};
  async_hooks_cn.AsyncResource = AsyncResource;
  async_hooks_cn.supported = false;
  module.exports = async_hooks_cn;
}
