Skip to content

Commit

Permalink
JS: Switch from new Buffer to Buffer.from
Browse files Browse the repository at this point in the history
Summary:
Constructing `Buffer` using the constructor [[https://nodesource.com/blog/understanding-the-buffer-deprecation-in-node-js-10/ | has been deprecated in Node 10 due to security considerations]].

This is a simple and straightforward conversion.

Reviewed By: mjesun

Differential Revision: D13080655

fbshipit-source-id: 100d8f28c3b255422b26e820aaadcc4f32f41e0d
  • Loading branch information
yungsters authored and facebook-github-bot committed Nov 15, 2018
1 parent 5939d07 commit d9c2cda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion RNTester/js/websocket_test_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ server.on('connection', ws => {
console.log('Received message:', message);
console.log('Cookie:', ws.upgradeReq.headers.cookie);
if (respondWithBinary) {
message = new Buffer(message);
message = Buffer.from(message);
}
if (message === 'getImage') {
message = fs.readFileSync(path.resolve(__dirname, 'flux@3x.png'));
Expand Down
4 changes: 2 additions & 2 deletions local-cli/generator/promptSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function create() {
process.stdin.setRawMode(true);
}

var buf = new Buffer(3);
var buf = Buffer.from(3);

This comment has been minimized.

Copy link
@dulmandakh

dulmandakh Nov 16, 2018

Contributor

it should be Buffer.alloc(3)

var str = '',
character,
read;
Expand All @@ -62,7 +62,7 @@ function create() {
insert = str.length;
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G');
buf = new Buffer(3);
buf = Buffer.from(3);

This comment has been minimized.

Copy link
@dulmandakh

dulmandakh Nov 16, 2018

Contributor

it should be Buffer.alloc(3)

}
continue; // any other 3 character sequence is ignored
}
Expand Down
6 changes: 3 additions & 3 deletions local-cli/server/util/copyToClipBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ function copyToClipBoard(content) {
switch (process.platform) {
case 'darwin':
var child = spawn('pbcopy', []);
child.stdin.end(new Buffer(content, 'utf8'));
child.stdin.end(Buffer.from(content, 'utf8'));
return true;
case 'win32':
var child = spawn('clip', []);
child.stdin.end(new Buffer(content, 'utf8'));
child.stdin.end(Buffer.from(content, 'utf8'));
return true;
case 'linux':
var child = spawn(xsel, ['--clipboard', '--input']);
child.stdin.end(new Buffer(content, 'utf8'));
child.stdin.end(Buffer.from(content, 'utf8'));
return true;
default:
return false;
Expand Down

0 comments on commit d9c2cda

Please sign in to comment.