Skip to content

Commit d9c2cda

Browse files
yungstersfacebook-github-bot
authored andcommitted
JS: Switch from new Buffer to Buffer.from
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
1 parent 5939d07 commit d9c2cda

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

RNTester/js/websocket_test_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ server.on('connection', ws => {
3535
console.log('Received message:', message);
3636
console.log('Cookie:', ws.upgradeReq.headers.cookie);
3737
if (respondWithBinary) {
38-
message = new Buffer(message);
38+
message = Buffer.from(message);
3939
}
4040
if (message === 'getImage') {
4141
message = fs.readFileSync(path.resolve(__dirname, '[email protected]'));

local-cli/generator/promptSync.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function create() {
4343
process.stdin.setRawMode(true);
4444
}
4545

46-
var buf = new Buffer(3);
46+
var buf = Buffer.from(3);
4747
var str = '',
4848
character,
4949
read;
@@ -62,7 +62,7 @@ function create() {
6262
insert = str.length;
6363
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
6464
process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G');
65-
buf = new Buffer(3);
65+
buf = Buffer.from(3);
6666
}
6767
continue; // any other 3 character sequence is ignored
6868
}

local-cli/server/util/copyToClipBoard.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ function copyToClipBoard(content) {
2323
switch (process.platform) {
2424
case 'darwin':
2525
var child = spawn('pbcopy', []);
26-
child.stdin.end(new Buffer(content, 'utf8'));
26+
child.stdin.end(Buffer.from(content, 'utf8'));
2727
return true;
2828
case 'win32':
2929
var child = spawn('clip', []);
30-
child.stdin.end(new Buffer(content, 'utf8'));
30+
child.stdin.end(Buffer.from(content, 'utf8'));
3131
return true;
3232
case 'linux':
3333
var child = spawn(xsel, ['--clipboard', '--input']);
34-
child.stdin.end(new Buffer(content, 'utf8'));
34+
child.stdin.end(Buffer.from(content, 'utf8'));
3535
return true;
3636
default:
3737
return false;

0 commit comments

Comments
 (0)