Files
lodash/.internal/nodeTypes.js
Joyee Cheung 363fef0efc internal: use util.types to migrate DEP0103 in Node.js (#3704)
- Use require('util').types instead of using process.binding('util')
  to get the type checking helpers
- Rename nodeUtil to nodeTypes since that is what it is for

Refs: https://github.com/nodejs/node/pull/18415
2018-03-23 07:31:36 -07:00

29 lines
1.1 KiB
JavaScript

import freeGlobal from './freeGlobal.js'
/** Detect free variable `exports`. */
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
/** Detect free variable `module`. */
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
/** Detect the popular CommonJS extension `module.exports`. */
const moduleExports = freeModule && freeModule.exports === freeExports
/** Detect free variable `process` from Node.js. */
const freeProcess = moduleExports && freeGlobal.process
/** Used to access faster Node.js helpers. */
const nodeTypes = ((() => {
try {
/* Detect public `util.types` helpers for Node.js v10+. */
/* Node.js deprecation code: DEP0103. */
const typesHelper = freeModule && freeModule.require && freeModule.require('util').types
return typesHelper
? typesHelper
/* Legacy process.binding('util') for Node.js earlier than v10. */
: freeProcess && freeProcess.binding && freeProcess.binding('util')
} catch (e) {}
})())
export default nodeTypes