_nodeUtil.js 995 B

123456789101112131415161718192021222324252627282930
  1. var freeGlobal = require('./_freeGlobal');
  2. /** Detect free variable `exports`. */
  3. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  4. /** Detect free variable `module`. */
  5. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  6. /** Detect the popular CommonJS extension `module.exports`. */
  7. var moduleExports = freeModule && freeModule.exports === freeExports;
  8. /** Detect free variable `process` from Node.js. */
  9. var freeProcess = moduleExports && freeGlobal.process;
  10. /** Used to access faster Node.js helpers. */
  11. var nodeUtil = (function() {
  12. try {
  13. // Use `util.types` for Node.js 10+.
  14. var types = freeModule && freeModule.require && freeModule.require('util').types;
  15. if (types) {
  16. return types;
  17. }
  18. // Legacy `process.binding('util')` for Node.js < 10.
  19. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  20. } catch (e) {}
  21. }());
  22. module.exports = nodeUtil;