mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
- 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
29 lines
1.1 KiB
JavaScript
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
|