Skip to content

Commit

Permalink
[fix] Replace deprecated Buffer usage (#565)
Browse files Browse the repository at this point in the history
The `Buffer` constructor has been deprecated in favor of safer alternatives.
See https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/
  • Loading branch information
oliversalzburg authored and darrachequesne committed Nov 19, 2018
1 parent 2c856ca commit 8e38a3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var server = engine.listen(80);

server.on('connection', function(socket){
socket.send('utf 8 string');
socket.send(new Buffer([0, 1, 2, 3, 4, 5])); // binary data
socket.send(Buffer.from([0, 1, 2, 3, 4, 5])); // binary data
});
```

Expand Down
3 changes: 1 addition & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ Server.prototype.handleUpgrade = function (req, socket, upgradeHead) {
return;
}

var head = new Buffer(upgradeHead.length); // eslint-disable-line node/no-deprecated-api
upgradeHead.copy(head);
var head = Buffer.from(upgradeHead); // eslint-disable-line node/no-deprecated-api
upgradeHead = null;

// delegate to ws
Expand Down

0 comments on commit 8e38a3c

Please sign in to comment.