Skip to content

Commit 5c9a28c

Browse files
committed
Fix scala-js/scala-js#3351: Use Buffer.alloc and Buffer.from instead of new Buffer().
The latter was deprecated a long time ago, and has started printing noisy warnings to the console in Node.js v10. There is still one deprecation inside jszip, but there is nothing we can do about that one.
1 parent 1135bac commit 5c9a28c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

js-envs/src/main/scala/org/scalajs/jsenv/nodejs/AbstractNodeJSEnv.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ abstract class AbstractNodeJSEnv(
172172
| var recvCallback = null;
173173
|
174174
| // Buffers received data
175-
| var inBuffer = new Buffer(0);
175+
| var inBuffer = Buffer.alloc(0);
176176
|
177177
| function onData(data) {
178178
| inBuffer = Buffer.concat([inBuffer, data]);
@@ -227,7 +227,7 @@ abstract class AbstractNodeJSEnv(
227227
| if (socket === null) throw new Error("Com not open");
228228
|
229229
| var len = msg.length;
230-
| var buf = new Buffer(4 + len * 2);
230+
| var buf = Buffer.allocUnsafe(4 + len * 2);
231231
| buf.writeInt32BE(len, 0);
232232
| for (var i = 0; i < len; ++i)
233233
| buf.writeUInt16BE(msg.charCodeAt(i), 4 + i * 2);

0 commit comments

Comments
 (0)