Skip to content
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

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

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

joyeecheung
Copy link
Contributor

@joyeecheung joyeecheung commented Mar 23, 2018

  • 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: nodejs/node#18415

Here is what I used to test this script:

arr.js

import isArrayBuffer from './isArrayBuffer.js'
import isDate from './isDate.js'
import isMap from './isMap.js'
import isRegExp from './isRegExp.js'
import isSet from './isSet.js'
import isTypedArray from './isTypedArray.js'

const arr = [
  isArrayBuffer(new Uint8Array().buffer),
  isDate(new Date()),
  isMap(new Map()),
  isRegExp(/test/),
  isSet(new Set()),
  isTypedArray(new Uint8Array())
]

export default arr

test.js

'use strict';
const a = require('./bundle');
console.log(a);
wget https://nodejs.org/download/nightly/v10.0.0-nightly20180322e714da6f0a/node-v10.0.0-nightly20180322e714da6f0a-darwin-x64.tar.xz
tar xf node-v10.0.0-nightly20180322e714da6f0a-darwin-x64.tar.xz

git checkout master
rollup arr.js --output.format cjs --output.file bundle.js
node-v10.0.0-nightly20180322e714da6f0a-darwin-x64/bin/node --pending-deprecation --trace-warnings test.js
# [ true, true, true, true, true, true ]
# [DEP0103] DeprecationWarning: Accessing native typechecking bindings of Node directly is deprecated. Please use `util.types.isArrayBuffer` instead.

git checkout node-dep-0103
rollup arr.js --output.format cjs --output.file bundle.js
node-v10.0.0-nightly20180322e714da6f0a-darwin-x64/bin/node --pending-deprecation --trace-warnings test.js
# [ true, true, true, true, true, true ]
# no warnings

- 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: nodejs/node#18415
@jsf-clabot
Copy link

jsf-clabot commented Mar 23, 2018

CLA assistant check
All committers have signed the CLA.

@jdalton jdalton merged commit 363fef0 into lodash:master Mar 23, 2018
@jdalton
Copy link
Member

jdalton commented Mar 23, 2018

Thanks @joyeecheung!

I'll backport this for Lodash v4 so the 30,000+ packages that depend on it will get the update too.

@lock
Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

3 participants