replace deprecated New Buffer() with Buffer.from()#3330
Conversation
|
Mocha still support node.js v4 and Buffer.from is introduced since v5.10.0. |
|
@outsideris Line 165 in 92beda9 The tests pass on node 4 even with this change. It seems the harry@home:~$ nvm use 4.4
Now using node v4.4.7 (npm v2.15.8)
harry@home:~$ node
> Buffer.from('hi')
TypeError: this is not a typed array.
at Function.from (native)
at repl:1:8
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:82:20)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
> .exit
harry@home:~$ nvm use 4.5
Now using node v4.5.0 (npm v2.15.9)
harry@home:~$ node
> Buffer.from('hi')
<Buffer 68 69>
|
|
LGTM. Netlify failure unrelated. @harrysarson Thanks! |
|
@harrysarson My bad. I didn't know that node v4 support |
|
No worries, the node docs are definately unclear about this. |
|
Yeah, I had to dig into the commit history to figure it out 😝 |
This Pull Request updates dependency [mocha](https://github.com/mochajs/mocha) from `~5.1.0` to `~5.2.0` <details> <summary>Release Notes</summary> ### [`v5.2.0`](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#​520--2018-05-18) [Compare Source](mochajs/mocha@v5.1.1...v5.2.0) #### 🎉 Enhancements - [#​3375]: Add support for comments in `mocha.opts` ([@​plroebuck]) #### 🐛 Fixes - [#​3346]: Exit correctly from `before` hooks when using `--bail` ([@​outsideris]) #### 📖 Documentation - [#​3328]: Mocha-flavored [API docs](https://mochajs.org/api/)! ([@​Munter]) #### 🔩 Other - [#​3330]: Use `Buffer.from()` ([@​harrysarson]) - [#​3295]: Remove redundant folder ([@​DavNej]) - [#​3356](`https://github.com/mochajs/mocha/pull/3356`): Refactoring ([@​plroebuck]) [#​3375]: `https://github.com/mochajs/mocha/pull/3375` [#​3346]: `https://github.com/mochajs/mocha/pull/3346` [#​3328]: `https://github.com/mochajs/mocha/pull/3328` [#​3330]: `https://github.com/mochajs/mocha/pull/3330` [#​3295]: `https://github.com/mochajs/mocha/pull/3295` [@​plroebuck]: https://github.com/plroebuck [@​harrysarson]: https://github.com/harrysarson [@​outsideris]: https://github.com/outsideris [@​Munter]: https://github.com/Munter --- </details> --- This PR has been generated by [Renovate Bot](https://renovatebot.com).
Description of Change
new Buffer()is set to be run time deprecated in node v10 (see nodejs/node#19079 and https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor).I swapped out the usage of
new Buffer()forBuffer.from()in mocha's integration tests.This should be semver patch.