8000 internal: use util.types to migrate DEP0103 in Node.js by joyeecheung · Pull Request #3704 · lodash/lodash · GitHub
[go: up one dir, main page]

Skip to content

internal: use util.types to migrate DEP0103 in Node.js #3704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .internal/nodeUtil.js → .internal/nodeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ const moduleExports = freeModule && freeModule.exports === freeExports
const freeProcess = moduleExports && freeGlobal.process

/** Used to access faster Node.js helpers. */
const nodeUtil = ((() => {
const nodeTypes = ((() => {
try {
return freeProcess && freeProcess.binding && freeProcess.binding('util')
/* 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 nodeUtil
export default nodeTypes
4 changes: 2 additions & 2 deletions isArrayBuffer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import baseGetTag from './.internal/baseGetTag.js'
import isObjectLike from './isObjectLike.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'

/* Node.js helper references. */
const nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer
const nodeIsArrayBuffer = nodeTypes && nodeTypes.isArrayBuffer

/**
* Checks if `value` is classified as an `ArrayBuffer` object.
Expand Down
4 changes: 2 additions & 2 deletions isDate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import baseGetTag from './.internal/baseGetTag.js'
import isObjectLike from './isObjectLike.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'

/* Node.js helper references. */
const nodeIsDate = nodeUtil && nodeUtil.isDate
const nodeIsDate = nodeTypes && nodeTypes.isDate

/**
* Checks if `value` is classified as a `Date` object.
Expand Down
4 changes: 2 additions & 2 deletions isMap.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import getTag from './.internal/getTag.js'
import isObjectLike from './isObjectLike.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'

/* Node.js helper references. */
const nodeIsMap = nodeUtil && nodeUtil.isMap
const nodeIsMap = nodeTypes && nodeTypes.isMap

/**
* Checks if `value` is classified as a `Map` object.
Expand Down
4 changes: 2 additions & 2 deletions isRegExp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import baseGetTag from './.internal/baseGetTag.js'
import isObjectLike from './isObjectLike.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'

/* Node.js helper references. */
const nodeIsRegExp = nodeUtil && nodeUtil.isRegExp
const nodeIsRegExp = nodeTypes && nodeTypes.isRegExp

/**
* Checks if `value` is classified as a `RegExp` object.
Expand Down
4 changes: 2 additions & 2 deletions isSet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import getTag from './.internal/getTag.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'
import isObjectLike from './isObjectLike'

/* Node.js helper references. */
const nodeIsSet = nodeUtil && nodeUtil.isSet
const nodeIsSet = nodeTypes && nodeTypes.isSet

/**
* Checks if `value` is classified as a `Set` object.
Expand Down
4 changes: 2 additions & 2 deletions isTypedArray.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import getTag from './.internal/getTag.js'
import nodeUtil from './.internal/nodeUtil.js'
import nodeTypes from './.internal/nodeTypes.js'
import isObjectLike from './isObjectLike'

/** Used to match `toStringTag` values of typed arrays. */
const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)\]$/

/* Node.js helper references. */
const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray
const nodeIsTypedArray = nodeTypes && nodeTypes.isTypedArray

/**
* Checks if `value` is classified as a typed array.
Expand Down
0