Fix allocating Buffer in early commit (#22379)
Summary:
Commit d9c2cdae41
brings compatibility with Node 10, but replaced allocating buffer incorrectly.
dulmandakh made two comments and shows how to do it based on NodeJS documentation https://nodejs.org/api/buffer.html#buffer_new_buffer_size
This PR just fixes that commit.
Pull Request resolved: https://github.com/facebook/react-native/pull/22379
Differential Revision: D13166867
Pulled By: hramos
fbshipit-source-id: 207528739889c044021a4b97ef94c33d56de3e89
This commit is contained in:
Родитель
0a293a014b
Коммит
02a3517d0b
|
@ -43,7 +43,7 @@ function create() {
|
||||||
process.stdin.setRawMode(true);
|
process.stdin.setRawMode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf = Buffer.from(3);
|
var buf = Buffer.alloc(3);
|
||||||
var str = '',
|
var str = '',
|
||||||
character,
|
character,
|
||||||
read;
|
read;
|
||||||
|
@ -62,7 +62,7 @@ function create() {
|
||||||
insert = str.length;
|
insert = str.length;
|
||||||
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
|
process.stdout.write('\u001b[2K\u001b[0G' + ask + str);
|
||||||
process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G');
|
process.stdout.write('\u001b[' + (insert + ask.length + 1) + 'G');
|
||||||
buf = Buffer.from(3);
|
buf = Buffer.alloc(3);
|
||||||
}
|
}
|
||||||
continue; // any other 3 character sequence is ignored
|
continue; // any other 3 character sequence is ignored
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче